diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index e5aae08ca3cec625b8f198de2ae89d037b32544e..bac638927c04f95f985987ca7c047b9abecd29ad 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -39,8 +39,8 @@ $langs->load("users"); $langs->load("mails"); -$action=GETPOST('action','alpha'); -$rowid=GETPOST('rowid','int'); +$action=GETPOST('action','alpha'); +$rowid=GETPOST('rowid','int'); $typeid=GETPOST('typeid','int'); // Security check diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 532d9c466ff3841114852245c7b50f3f87246f7f..83b2c24dbc5b6741b77ed694f929d74444de5536 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1008,7 +1008,7 @@ class Adherent extends CommonObject if ($rowid) $sql.= " AND d.rowid=".$rowid; elseif ($ref || $fk_soc) { $sql.= " AND d.entity IN (".getEntity().")"; - if ($ref) $sql.= " AND d.rowid='".$ref."'"; + if ($ref) $sql.= " AND d.rowid='".$ref."'"; elseif ($fk_soc) $sql.= " AND d.fk_soc='".$fk_soc."'"; } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index b838294770b6e78631d70dbfc28a9939c25f579d..5b7ca0d26146152c156a689d09e666a160bcb5f4 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -35,7 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); $langs->load("members"); $langs->load("companies"); $langs->load('other'); - + $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 2d72004f6a0a3be94cdc89be8d4e6c0887fc2af5..650ec5016afcb21ca9bf030aef87025538efbfc2 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -42,12 +42,12 @@ $langs->load("members"); $langs->load("users"); -$action=GETPOST('action','alpha'); +$action=GETPOST('action','alpha'); $backtopage=GETPOST('backtopage','alpha'); -$confirm=GETPOST('confirm','alpha'); -$rowid=GETPOST('rowid','int'); -$typeid=GETPOST('typeid','int'); -$userid=GETPOST('userid','int'); +$confirm=GETPOST('confirm','alpha'); +$rowid=GETPOST('rowid','int'); +$typeid=GETPOST('typeid','int'); +$userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); // Security check diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index a99ae0579257ad284a101b9287f0956113f5b2d5..5ede330a911df3e9bd5d8ccb9abc434f628a19bf 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -27,14 +27,14 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); -$langs->load("companies"); -$langs->load("members"); +$langs->load("companies"); +$langs->load("members"); $langs->load("bills"); $action=GETPOST('action','alpha'); $id=GETPOST('id','int'); -// Security check +// Security check $result=restrictedArea($user,'adherent',$id); $object = new Adherent($db); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 16203fecde3e589bc156e02b5b6ff668cab88e99..80ec61b3f982475eb043ecc7515e4fc95abd3e86 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -49,7 +49,7 @@ $pagenext = $page + 1; if (! $sortorder) { $sortorder="DESC"; } if (! $sortfield) { $sortfield="d.nom"; } -// Security check +// Security check $result=restrictedArea($user,'adherent',$rowid,'adherent_type'); if (GETPOST('button_removefilter')) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ea7dcd7c4ab51c49a57109bfa4a8d4dec93e1b6c..71ec16150b65037ccf0424da618769acfec9df04 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -913,8 +913,8 @@ if ($id) else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; } - else if ($fieldlist[$field]=='unicode') { - $valuetoshow = getCurrencySymbol($obj->code); + else if ($fieldlist[$field]=='unicode') { + $valuetoshow = getCurrencySymbol($obj->code); } if ($showfield) print '<td>'.$valuetoshow.'</td>'; } diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index b78dfb92797bd0985322a89706a157ec2417b5c5..b71cdb76e2a63c3f3532a0bf52abcded6dff129e 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -77,7 +77,7 @@ if ($action == 'specimen') if ($action == 'setdoc') { $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); + $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $db->begin(); @@ -111,8 +111,8 @@ if ($action == 'setdoc') if ($action == 'set') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); + $value = GETPOST('value','alpha'); + $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='donation'; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 9ddd160b7e3b2d7ba59a5a6c875ed2043ae3fb5d..d2c93328129d5ff01039f73dd030b0c29d0e96ec 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -38,9 +38,9 @@ $langs->load("interventions"); if (! $user->admin) accessforbidden(); -$action = GETPOST('action','alpha'); -$value = GETPOST('value','alpha'); -$label = GETPOST('label','alpha'); +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='ficheinter'; @@ -334,8 +334,8 @@ print "</tr>\n"; clearstatcache(); $var=true; -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) +{ $dir = dol_buildpath($reldir."core/modules/fichinter/doc/"); if (is_dir($dir)) diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index b433731f1f685bc992cbf9589864f1a5e12acdc2..64abda9ce27b27cc770274edb8479a53d0253718 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -163,7 +163,7 @@ if ($action == 'specimenfacture') // For invoices if ($action == 'set') { - $label = GETPOST('label','alpha'); + $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; @@ -195,7 +195,7 @@ if ($action == 'del') if ($action == 'setdoc') { - $label = GETPOST('label','alpha'); + $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $db->begin(); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 3fa267ece70260dbee4f0dfd7560db5940385e7b..3be1da76b8bf606ca06b9cb9e287e59ed9de7448 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -209,12 +209,12 @@ if ($action == 'edit') // Edit print '<td width="20"> </td>'; print '</tr>'; - // Hide unauthorized button - $var=!$var; - print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>'; - print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1); - print '</td>'; - print '<td width="20"> </td>'; + // Hide unauthorized button + $var=!$var; + print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td>'; + print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1); + print '</td>'; + print '<td width="20"> </td>'; print '</tr>'; // Hide helpcenter link on login page @@ -367,10 +367,10 @@ else // Show print '<td width="20"> </td>'; print '</tr>'; - // Hide unauthorized button - $var=!$var; - print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">'; - print yn($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED,1); + // Hide unauthorized button + $var=!$var; + print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ButtonHideUnauthorized").'</td><td colspan="2">'; + print yn($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED,1); print '</td></tr>'; // Link to help center diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 6f216bbdac1c7fbfdb38589018418a7af92ec4f6..193247fe8da54cb896ffc7a5383ebf5fa887a66f 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -34,8 +34,8 @@ if (! $user->admin) accessforbidden(); $dirstandard = array(); $dirsmartphone = array(); -$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); -foreach($dirmenus as $dirmenu) +$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); +foreach($dirmenus as $dirmenu) { $dirstandard[]=$dirmenu.'standard'; $dirsmartphone[]=$dirmenu.'smartphone'; diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 84fcc06d462578415beabb41f7a1b5ef7f15a461..5842587b5e89f88c434d533b67fa594e7ec90c59 100755 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -212,9 +212,9 @@ if ($action == 'edit') // Edit if ($conf->global->MAIN_FEATURES_LEVEL > 1) { //Desc - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; - print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0,1); + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DESC',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC:0,1); print '</td></tr>'; //Ref @@ -223,10 +223,10 @@ if ($action == 'edit') // Edit print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_REF',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF:0,1); print '</td></tr>'; - //Details - $var=!$var; + //Details + $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; - print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1); + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1); print '</td></tr>'; } @@ -371,25 +371,25 @@ else // Show print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); print '</td></tr>'; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - //Desc - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; - print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1); - print '</td></tr>'; - - //Ref - $var=!$var; - print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>'; - print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1); - print '</td></tr>'; - - //Details - $var=!$var; + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + //Desc + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDescOnPDF").'</td><td>'; + print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC,1); + print '</td></tr>'; + + //Ref + $var=!$var; + print '<tr '.$bc[$var].'><td>'.$langs->trans("HideRefOnPDF").'</td><td>'; + print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF,1); + print '</td></tr>'; + + //Details + $var=!$var; print '<tr '.$bc[$var].'><td>'.$langs->trans("HideDetailsOnPDF").'</td><td>'; - print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); - print '</td></tr>'; + print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); + print '</td></tr>'; } print '</table>'; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 757e8125a4fef6424ad6b2ce5acda58725d675f9..007c0eadf9e96ba43e610b83a18b8e85cbd30be9 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -39,7 +39,7 @@ if (! $user->admin) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); -$label = GETPOST('label','alpha'); +$label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='propal'; @@ -207,7 +207,7 @@ else if ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 3af2b62f24bc735041febeba6d025f3dcb810e36..52da5ba5325ef997bf63da85c773606ab0e98442 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -165,7 +165,7 @@ $daylight=(is_numeric($c) && is_numeric($b))?round($c-$b):'unknown'; $val=($a>=0?'+':'').$a; $val.=' ('.($a==='unknown'?'unknown':($a>=0?'+':'').($a*3600)).')'; $val.=' '.getServerTimeZoneString(); -$val.=' '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':yn($daylight)); +$val.=' '.$langs->trans("DaylingSavingTime").': '.($daylight==='unknown'?'unknown':yn($daylight)); print $form->textwithtooltip($val,$txt,2,1,img_info('')); print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php $var=!$var; diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 47e53ace4b2cdda3c267b476b003e7c28bb7e9d3..567dcfc83237b5f0099c289510a7da8087cb2726 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -79,7 +79,7 @@ if (GETPOST('action','alpha')=='install') $result=dol_uncompress($newfile,$documentrootalt); if (! empty($result['error'])) { - $langs->load("errors"); + $langs->load("errors"); $mesg = '<div class="error">'.$langs->trans($result['error'],$original_file).'</div>'; } @@ -95,8 +95,8 @@ if (GETPOST('action','alpha')=='install') * View */ -$dirins=DOL_DOCUMENT_ROOT_ALT; -$dirins_ok=(is_dir($dirins)); +$dirins=DOL_DOCUMENT_ROOT_ALT; +$dirins_ok=(is_dir($dirins)); $wikihelp='EN:Installation_-_Upgrade|FR:Installation_-_Mise_à_jour|ES:Instalación_-_Actualización'; llxHeader('',$langs->trans("Upgrade"),$wikihelp); @@ -150,14 +150,14 @@ if (! empty($conf->global->MAIN_ONLINE_INSTALL_MODULE)) print '</form>'; } else - { - $message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); - print $message; + { + $message=info_admin($langs->trans("NotExistsDirect").$langs->trans("InfDirAlt").$langs->trans("InfDirExample")); + print $message; } } else { - print '<b>'.$langs->trans("StepNb",4).'</b>: '; + print '<b>'.$langs->trans("StepNb",4).'</b>: '; print $langs->trans("SetupIsReadyForUse").'<br>'; } print '</form>'; diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index d25a5520e22da3c991b2e1355fee499f8b71d894..d8d315c199a5542f44b6f10522e1be2e54c0270e 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -51,11 +51,11 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if ($id > 0) -{ - $result = $object->fetch($id); - - $upload_dir = $conf->categorie->multidir_output[$object->entity]; +if ($id > 0) +{ + $result = $object->fetch($id); + + $upload_dir = $conf->categorie->multidir_output[$object->entity]; } @@ -89,207 +89,207 @@ $form = new Form($db); if ($object->id) { - $title=$langs->trans("ProductsCategoryShort"); - if ($type == 0) $title=$langs->trans("ProductsCategoryShort"); - elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort"); - elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort"); - elseif ($type == 3) $title=$langs->trans("MembersCategoryShort"); - - $head = categories_prepare_head($object,$type); - dol_fiche_head($head, 'photos', $title, 0, 'category'); - - /* - * Confirmation de la suppression de photo - */ - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); - if ($ret == 'html') print '<br>'; - } - - print($mesg); - - print '<table class="border" width="100%">'; - - // Path of category - print '<tr><td width="20%" class="notopnoleft">'; - $ways = $object->print_all_ways(); - print $langs->trans("Ref").'</td><td>'; - print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> '; - foreach ($ways as $way) - { - print $way."<br>\n"; - } - print '</td></tr>'; - - // Description - print '<tr><td width="20%" class="notopnoleft">'; - print $langs->trans("Description").'</td><td>'; - print nl2br($object->description); - print '</td></tr>'; - - // Visibility - /* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) - { - if ($object->socid) - { - $soc = new Societe($db); - $soc->fetch($object->socid); - - print '<tr><td width="20%" class="notopnoleft">'; - print $langs->trans("AssignedToTheCustomer").'</td><td>'; - print $soc->getNomUrl(1); - print '</td></tr>'; - - $catsMeres = $object->get_meres (); - - if ($catsMeres < 0) - { - dol_print_error(); - } - else if (count($catsMeres) > 0) - { - print '<tr><td width="20%" class="notopnoleft">'; - print $langs->trans("CategoryContents").'</td><td>'; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '</td></tr>'; - } - } - else - { - print '<tr><td width="20%" class="notopnoleft">'; - print $langs->trans("CategoryContents").'</td><td>'; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '</td></tr>'; - } - } - else - { - print '<tr><td width="20%" class="notopnoleft">'; - print $langs->trans("CategoryContents").'</td><td>'; - print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); - print '</td></tr>'; - } - */ - - print "</table>\n"; - - print "</div>\n"; - - - - /* ************************************************************************** */ - /* */ - /* Barre d'action */ - /* */ - /* ************************************************************************** */ - - print "\n<div class=\"tabsAction\">\n"; - - if ($action != 'ajout_photo' && $user->rights->categorie->creer) - { - if (! empty($conf->global->MAIN_UPLOAD_DOC)) - { - print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&id='.$object->id.'&type='.$type.'">'; - print $langs->trans("AddPhoto").'</a>'; - } - else - { - print '<a class="butActionRefused" href="#">'; - print $langs->trans("AddPhoto").'</a>'; - } - } - - print "\n</div>\n"; - - /* - * Ajouter une photo - */ - if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) - { - // Affiche formulaire upload - $formfile=new FormFile($db); - $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type,$langs->trans("AddPhoto"),1); - } - - // Affiche photos - if ($action != 'ajout_photo') - { - $nbphoto=0; - $nbbyrow=5; - - $maxWidth = 160; - $maxHeight = 120; - - $pdir = get_exdir($object->id,2) . $object->id ."/photos/"; - $dir = $upload_dir.'/'.$pdir; - - print '<br>'; - print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; - - foreach ($object->liste_photos($dir) as $key => $obj) - { - $nbphoto++; - - - if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; - if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; - - print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; - - // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine - if ($obj['photo_vignette']) - { - $filename='thumbs/'.$obj['photo_vignette']; - } - else - { - $filename=$obj['photo']; - } - - // Nom affiche - $viewfilename=$obj['photo']; - - // Taille de l'image - $object->get_image_size($dir.$filename); - $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; - $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; - - print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">'; - - print '</a>'; - print '<br>'.$viewfilename; - print '<br>'; - - // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites - if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) - { - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>'; - } - if ($user->rights->categorie->creer) - { - print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=delete&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'; - print img_delete().'</a>'; - } - if ($nbbyrow) print '</td>'; - if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; - } - - // Ferme tableau - while ($nbphoto % $nbbyrow) - { - print '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; - $nbphoto++; - } - - if ($nbphoto < 1) - { - print '<tr align=center valign=middle border=1><td class="photo">'; - print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; - print '</td></tr>'; - } - - print '</table>'; + $title=$langs->trans("ProductsCategoryShort"); + if ($type == 0) $title=$langs->trans("ProductsCategoryShort"); + elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort"); + elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort"); + elseif ($type == 3) $title=$langs->trans("MembersCategoryShort"); + + $head = categories_prepare_head($object,$type); + dol_fiche_head($head, 'photos', $title, 0, 'category'); + + /* + * Confirmation de la suppression de photo + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&file='.$_GET["file"], $langs->trans('DeletePicture'), $langs->trans('ConfirmDeletePicture'), 'confirm_delete', '', 0, 1); + if ($ret == 'html') print '<br>'; + } + + print($mesg); + + print '<table class="border" width="100%">'; + + // Path of category + print '<tr><td width="20%" class="notopnoleft">'; + $ways = $object->print_all_ways(); + print $langs->trans("Ref").'</td><td>'; + print '<a href="'.DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type.'">'.$langs->trans("Root").'</a> >> '; + foreach ($ways as $way) + { + print $way."<br>\n"; + } + print '</td></tr>'; + + // Description + print '<tr><td width="20%" class="notopnoleft">'; + print $langs->trans("Description").'</td><td>'; + print nl2br($object->description); + print '</td></tr>'; + + // Visibility + /* if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) + { + if ($object->socid) + { + $soc = new Societe($db); + $soc->fetch($object->socid); + + print '<tr><td width="20%" class="notopnoleft">'; + print $langs->trans("AssignedToTheCustomer").'</td><td>'; + print $soc->getNomUrl(1); + print '</td></tr>'; + + $catsMeres = $object->get_meres (); + + if ($catsMeres < 0) + { + dol_print_error(); + } + else if (count($catsMeres) > 0) + { + print '<tr><td width="20%" class="notopnoleft">'; + print $langs->trans("CategoryContents").'</td><td>'; + print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); + print '</td></tr>'; + } + } + else + { + print '<tr><td width="20%" class="notopnoleft">'; + print $langs->trans("CategoryContents").'</td><td>'; + print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); + print '</td></tr>'; + } + } + else + { + print '<tr><td width="20%" class="notopnoleft">'; + print $langs->trans("CategoryContents").'</td><td>'; + print ($object->visible ? $langs->trans("Visible") : $langs->trans("Invisible")); + print '</td></tr>'; + } + */ + + print "</table>\n"; + + print "</div>\n"; + + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + print "\n<div class=\"tabsAction\">\n"; + + if ($action != 'ajout_photo' && $user->rights->categorie->creer) + { + if (! empty($conf->global->MAIN_UPLOAD_DOC)) + { + print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=ajout_photo&id='.$object->id.'&type='.$type.'">'; + print $langs->trans("AddPhoto").'</a>'; + } + else + { + print '<a class="butActionRefused" href="#">'; + print $langs->trans("AddPhoto").'</a>'; + } + } + + print "\n</div>\n"; + + /* + * Ajouter une photo + */ + if ($action == 'ajout_photo' && $user->rights->categorie->creer && ! empty($conf->global->MAIN_UPLOAD_DOC)) + { + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file($_SERVER['PHP_SELF'].'?id='.$object->id.'&type='.$type,$langs->trans("AddPhoto"),1); + } + + // Affiche photos + if ($action != 'ajout_photo') + { + $nbphoto=0; + $nbbyrow=5; + + $maxWidth = 160; + $maxHeight = 120; + + $pdir = get_exdir($object->id,2) . $object->id ."/photos/"; + $dir = $upload_dir.'/'.$pdir; + + print '<br>'; + print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; + + foreach ($object->liste_photos($dir) as $key => $obj) + { + $nbphoto++; + + + if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; + if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; + + print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; + + // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine + if ($obj['photo_vignette']) + { + $filename='thumbs/'.$obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + + // Nom affiche + $viewfilename=$obj['photo']; + + // Taille de l'image + $object->get_image_size($dir.$filename); + $imgWidth = ($object->imgWidth < $maxWidth) ? $object->imgWidth : $maxWidth; + $imgHeight = ($object->imgHeight < $maxHeight) ? $object->imgHeight : $maxHeight; + + print '<img border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=category&entity='.$object->entity.'&file='.urlencode($pdir.$filename).'">'; + + print '</a>'; + print '<br>'.$viewfilename; + print '<br>'; + + // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites + if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($object->imgWidth > $maxWidth || $object->imgHeight > $maxHeight)) + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=addthumb&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>'; + } + if ($user->rights->categorie->creer) + { + print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->entity.'&action=delete&type='.$type.'&file='.urlencode($pdir.$viewfilename).'">'; + print img_delete().'</a>'; + } + if ($nbbyrow) print '</td>'; + if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; + } + + // Ferme tableau + while ($nbphoto % $nbbyrow) + { + print '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; + $nbphoto++; + } + + if ($nbphoto < 1) + { + print '<tr align=center valign=middle border=1><td class="photo">'; + print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; + print '</td></tr>'; + } + + print '</table>'; } } else diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index b4059a944453fa5b6aeadf324313d6ced751f5b8..c03f87538ca8e36b24eec2ceecaadf96c6b5c5be 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -51,11 +51,11 @@ $object = new Address($db); * Actions */ -// Cancel -if (GETPOST("cancel") && ! empty($backtopage)) -{ - header("Location: ".$backtopage); - exit; +// Cancel +if (GETPOST("cancel") && ! empty($backtopage)) +{ + header("Location: ".$backtopage); + exit; } if ($action == 'add' || $action == 'update') @@ -80,7 +80,7 @@ if ($action == 'add' || $action == 'update') { if (! empty($backtopage)) { - Header("Location: ".$backtopage); + Header("Location: ".$backtopage); exit; } else if ($origin == 'commande') @@ -93,10 +93,10 @@ if ($action == 'add' || $action == 'update') Header("Location: ../comm/propal/contact.php?action=editdelivery_adress&socid=".$socid."&id=".$originid); exit; } - elseif ($origin == 'shipment') - { - Header("Location: ../expedition/fiche.php?id=".$originid); - exit; + elseif ($origin == 'shipment') + { + Header("Location: ../expedition/fiche.php?id=".$originid); + exit; } else { @@ -118,10 +118,10 @@ if ($action == 'add' || $action == 'update') if ($result >= 0) { - if (! empty($backtopage)) - { - Header("Location: ".$backtopage); - exit; + if (! empty($backtopage)) + { + Header("Location: ".$backtopage); + exit; } else if ($origin == 'commande') { @@ -286,10 +286,10 @@ if ($action == 'create') print '<br><center>'; print '<input type="submit" class="button" value="'.$langs->trans('Add').'">'; - if (! empty($backtopage)) - { - print ' '; - print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; + if (! empty($backtopage)) + { + print ' '; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; } print '</center>'."\n"; @@ -384,10 +384,10 @@ elseif ($action == 'edit') print '</table><br>'; - print '<center>'; - print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; - print ' '; - print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; + print '<center>'; + print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">'; + print ' '; + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '</center>'; print '</form>'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 74aba8662a6e38db152a97467c75d007980cacc5..403fedddd15b91dfe3ab9d92ffd37a7e956515bc 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -92,7 +92,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $object = new Propal($db); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || ! empty($ref)) { $ret=$object->fetch($id, $ref); } @@ -159,29 +159,29 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->prop // Remove line else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propale->creer) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->deleteline($lineid); - // reorder lines - if ($result) $object->line_order(true); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - } - - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->deleteline($lineid); + // reorder lines + if ($result) $object->line_order(true); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); + } + + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } @@ -253,18 +253,18 @@ else if ($action == 'set_ref_client' && $user->rights->propale->creer) $object->set_ref_client($user, $_POST['ref_client']); } -else if ($action == 'setnote_public' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); +else if ($action == 'setnote_public' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } - -else if ($action == 'setnote' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); + +else if ($action == 'setnote' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } // Create proposal @@ -957,21 +957,21 @@ else if ($action == 'builddoc' && $user->rights->propale->creer) } } -// Remove file in doc form -else if ($action == 'remove_file') -{ - if ($object->fetch($id)) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $object->fetch_thirdparty(); - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file,0,0,0,$object); - $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; - } +// Remove file in doc form +else if ($action == 'remove_file') +{ + if ($object->fetch($id)) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->propal->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; + } } // Set project @@ -1071,63 +1071,63 @@ else if ($action == 'down' && $user->rights->propale->creer) if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->propale->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->propale->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; - } - else - { - $mesg = '<div class="error">'.$object->error.'</div>'; - } - } - } - - // Bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->propale->creer) - { - if ($object->fetch($id) > 0) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->propale->creer) - { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - dol_print_error($db); - } + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; + } + else + { + $mesg = '<div class="error">'.$object->error.'</div>'; + } + } + } + + // Bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->propale->creer) + { + if ($object->fetch($id) > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->propale->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + dol_print_error($db); + } } } @@ -1564,19 +1564,19 @@ print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" cols print '</table><br>'; -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $blocname = 'notes'; + $blocname = 'notes'; $title = $langs->trans('Notes'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7b78fd20f09d08a68b07fdcf643d21a597dadc4c..761f68cde5d179d98e56f1a73dae32eb00567afd 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -969,7 +969,7 @@ class Propal extends CommonObject $sql.= ", p.fk_cond_reglement"; $sql.= ", p.fk_mode_reglement"; $sql.= ", c.label as statut_label"; - $sql.= ", ca.code as availability_code, ca.label as availability"; + $sql.= ", ca.code as availability_code, ca.label as availability"; $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 53e8cd6475e592a7a670c22cb2a9d1b3203124de..5940c01c24784f025faae62a9bbdfa5b35b3d94c 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -39,11 +39,11 @@ $confirm = GETPOST('confirm','alpha'); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -67,9 +67,9 @@ if (! $sortfield) $sortfield="name"; $object = new Propal($db); $object->fetch($id,$ref); -if ($object->id > 0) -{ - $object->fetch_thirdparty(); +if ($object->id > 0) +{ + $object->fetch_thirdparty(); } /* @@ -148,70 +148,70 @@ $form = new Form($db); if ($object->id > 0) { - $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); - - $head = propal_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); - - - // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $totalsize=0; - foreach($filearray as $key => $file) - { - $totalsize+=$file['size']; - } - - - print '<table class="border"width="100%">'; - - $linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>'; - - // Ref - print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'; - print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); - print '</td></tr>'; - - // Ref client - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; - print $langs->trans('RefCustomer').'</td><td align="left">'; - print '</td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - print $object->ref_client; - print '</td>'; - print '</tr>'; - - // Customer - print "<tr><td>".$langs->trans("Company")."</td>"; - print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; - - print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; - - print '</table>'; - - print '</div>'; - - dol_htmloutput_mesg($mesg,$mesgs); - - /* - * Confirmation suppression fichier - */ - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); - if ($ret == 'html') print '<br>'; - } - - // Affiche formulaire upload - $formfile=new FormFile($db); - $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); - - - // List of document - $param='&id='.$object->id; + $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print '<table class="border"width="100%">'; + + $linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>'; + + // Ref + print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">'; + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); + print '</td></tr>'; + + // Ref client + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; + print $langs->trans('RefCustomer').'</td><td align="left">'; + print '</td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + print $object->ref_client; + print '</td>'; + print '</tr>'; + + // Customer + print "<tr><td>".$langs->trans("Company")."</td>"; + print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>'; + + print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; + + print '</table>'; + + print '</div>'; + + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '<br>'; + } + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object); + + + // List of document + $param='&id='.$object->id; $formfile->list_of_documents($filearray,$object,'propal',$param); } else diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index ea518da991a64b12d00a0ff74ff7011da23c2426..6063c21a8d0c153188796ea21323a8e3d8b38cb9 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -184,14 +184,14 @@ if ($conf->propal->enabled) $obj = $db->fetch_object($resql); print "<tr $bc[$var]>"; - $propalstatic->id=$obj->rowid; - $propalstatic->ref=$obj->ref; + $propalstatic->id=$obj->rowid; + $propalstatic->ref=$obj->ref; print '<td nowrap="nowrap">'.$propalstatic->getNomUrl(1).'</td>'; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; print '<td>'.$companystatic->getNomUrl(1,'customer',24).'</td>'; print '</tr>'; @@ -265,10 +265,10 @@ if ($resql) print '</td>'; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>'; @@ -340,10 +340,10 @@ if ($conf->propal->enabled && $user->rights->propale->lire) print "</td>"; - $companystatic->id=$obj->socid; - $companystatic->name=$obj->socname; - $companystatic->client=$obj->client; - $companystatic->canvas=$obj->canvas; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->socname; + $companystatic->client=$obj->client; + $companystatic->canvas=$obj->canvas; print '<td align="left">'.$companystatic->getNomUrl(1,'customer',44).'</td>'."\n"; print '<td align="right">'; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 0fbd9b060ca3da5faac94033ea682685d4949a11..f8f9f361cd0e48d10329ebb4e58a3e958ac50720 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -86,7 +86,7 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); $object = new Propal($db); // Load object -if ($id > 0 || ! empty($ref)) +if ($id > 0 || ! empty($ref)) { $ret=$object->fetch($id, $ref); } @@ -172,9 +172,9 @@ if ($search_ref) { $sql.= " AND p.ref LIKE '%".$db->escape(trim($search_ref))."%'"; } -if ($search_refcustomer) -{ - $sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'"; +if ($search_refcustomer) +{ + $sql.= " AND p.ref_client LIKE '%".$db->escape(trim($search_refcustomer))."%'"; } if ($search_societe) { @@ -284,8 +284,8 @@ if ($result) print '<td class="liste_titre" align="left">'; print '<input class="flat" type="text" size="16" name="search_societe" value="'.$search_societe.'">'; print '</td>'; - print '<td class="liste_titre">'; - print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">'; + print '<td class="liste_titre">'; + print '<input class="flat" size="10" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">'; print '</td>'; print '<td class="liste_titre" colspan="1" align="center">'; print $langs->trans('Month').': <input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; @@ -352,8 +352,8 @@ if ($result) print '</td>'; // Customer ref - print '<td nowrap="nowrap">'; - print $objp->ref_client; + print '<td nowrap="nowrap">'; + print $objp->ref_client; print '</td>'; // Date propale diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index d7d88029062d0dc61e72a116c7868ee4ec937fc5..0c90d58b1acdcab349ce36502fa0826f250d139d 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -47,18 +47,18 @@ $object = new Propal($db); /* Actions */ /******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->propale->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); +if ($action == 'setnote_public' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->propale->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e52b96e2856756d5b541b7700ed86e1a2dc9dd81..21ac189e5622a33e15ddf0a44a4155f8199c3234 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -921,13 +921,13 @@ class Commande extends CommonObject $this->note_public = $object->note_public; $this->origin = $object->element; - $this->origin_id = $object->id; - - // Possibility to add external linked objects with hooks - $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) - { - $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + $this->origin_id = $object->id; + + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } $ret = $this->create($user); @@ -937,7 +937,7 @@ class Commande extends CommonObject // Actions hooked (by external module) if (! is_object($hookmanager)) { - include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('orderdao')); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index dc664de96e92c95a5eed79d03d66f614f27df5d0..8386f77d88a5daa933cd83b2d42b40a439b73ee5 100755 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -163,7 +163,7 @@ if ($resql) $lienfin='</a>'; $name=$obj->nom; $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin); - $result.=$lien.(dol_trunc($name,$maxlen)).$lienfin; + $result.=$lien.(dol_trunc($name,$maxlen)).$lienfin; print $result; print '</td>'; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 84c2896e0e3d86a34804122980c682118abb2f13..e158495b0c277417f8444bc175cd60ba8365e4f2 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -40,11 +40,11 @@ $confirm = GETPOST('confirm'); $id = GETPOST('id','int'); $ref = GETPOST('ref'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -130,7 +130,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); exit; } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 74485eafb377dfb363d32365847830535402666e..dff7aa50de9136d1216a7a5a1225f325f4fe5e06 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -58,7 +58,7 @@ $confirm = GETPOST('confirm'); $lineid = GETPOST('lineid'); $mesg = GETPOST('mesg'); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -69,10 +69,10 @@ $result=restrictedArea($user,'commande',$id,''); $object = new Commande($db); -// Load object -if ($id > 0 || ! empty($ref)) -{ - $ret=$object->fetch($id, $ref); +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -512,18 +512,18 @@ else if ($action == 'setremiseabsolue' && $user->rights->commande->creer) $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } -else if ($action == 'setnote_public' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->commande->creer) -{ - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); +else if ($action == 'setnote_public' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->commande->creer) +{ + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } /* @@ -1227,64 +1227,64 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P } } -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->commande->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->commande->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; + } + else + { + $mesg = '<div class="error">'.$object->error.'</div>'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->commande->creer) + { + if ($object->fetch($id)) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; - } - else - { - $mesg = '<div class="error">'.$object->error.'</div>'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->commande->creer) - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->commande->creer) - { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->commande->creer) + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } } } @@ -2052,24 +2052,24 @@ else print '<td colspan="2">'.$object->getLibStatut(4).'</td>'; print '</tr>'; - print '</table><br>'; + print '</table><br>'; print "\n"; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } /* diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 16a45b0a7d9a2c731b83225042df1edf375ce604..a521f766574ffc4692ec71cd688470a5a21a6ae7 100755 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -44,7 +44,7 @@ $sref_client=GETPOST('sref_client'); $sall=GETPOST('sall'); $socid=GETPOST('socid','int'); -if (! $user->rights->facture->creer) +if (! $user->rights->facture->creer) accessforbidden(); $sortfield = GETPOST("sortfield",'alpha'); @@ -52,9 +52,9 @@ $sortorder = GETPOST("sortorder",'alpha'); if (! $sortfield) $sortfield='c.rowid'; if (! $sortorder) $sortorder='DESC'; -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server +$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); // Date for local PHP server $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); -$date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server +$date_starty=dol_mktime(0,0,0,$_REQUEST["date_start_delymonth"],$_REQUEST["date_start_delyday"],$_REQUEST["date_start_delyyear"]); // Date for local PHP server $date_endy=dol_mktime(23,59,59,$_REQUEST["date_end_delymonth"],$_REQUEST["date_end_delyday"],$_REQUEST["date_end_delyyear"]); $selected=GETPOST('orders_to_invoice'); $action=GETPOST('action','alpha'); @@ -78,399 +78,399 @@ $formfile = new FormFile($db); $companystatic = new Societe($db); $htmlother = new FormOther($db); -/* - * Actions +/* + * Actions */ if (($action == 'create' || $action == 'add') && ! $mesg ) { - require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); - require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); - require_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); - require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); - require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); - require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); - require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); - require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); - if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); - if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); - $langs->load('bills'); - $langs->load('products'); - $langs->load('main'); - if (isset($_GET['orders_to_invoice'])) - { - $orders_id = $_GET['orders_to_invoice']; - $n = count($orders_id); - $i = 0; - - $originid=$orders_id[0]; - $_GET['originid']=$orders_id[0]; - - } - if (isset($_POST['orders_to_invoice'])) - { - $orders_id = $_POST['orders_to_invoice']; - $nn = count($orders_id); - $ii = 0; - - $originid=$orders_id[0]; - $_POST['originid']=$orders_id[0]; - - } - if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; - $sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); - $projectid=isset($_GET['projectid'])?$_GET['projectid']:0; - $id =(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility - $ref =GETPOST('ref'); - $socid =GETPOST('socid'); - $action =GETPOST('action'); - $confirm =GETPOST('confirm'); - $lineid =GETPOST('lineid'); - $userid =GETPOST('userid'); - $search_ref =GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref'); - - // Security check - $fieldid = isset($_GET["ref"])?'facnumber':'rowid'; - if ($user->societe_id) $socid=$user->societe_id; - $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); - - $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; + require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); + require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); + require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); + require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); + require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); + require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); + if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); + if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); + $langs->load('bills'); + $langs->load('products'); + $langs->load('main'); + if (isset($_GET['orders_to_invoice'])) + { + $orders_id = $_GET['orders_to_invoice']; + $n = count($orders_id); + $i = 0; + + $originid=$orders_id[0]; + $_GET['originid']=$orders_id[0]; + + } + if (isset($_POST['orders_to_invoice'])) + { + $orders_id = $_POST['orders_to_invoice']; + $nn = count($orders_id); + $ii = 0; + + $originid=$orders_id[0]; + $_POST['originid']=$orders_id[0]; + + } + if (GETPOST('mesg','int',1) && isset($_SESSION['message'])) $mesg=$_SESSION['message']; + $sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); + $projectid=isset($_GET['projectid'])?$_GET['projectid']:0; + $id =(GETPOST('id')?GETPOST("id"):GETPOST("facid")); // For backward compatibility + $ref =GETPOST('ref'); + $socid =GETPOST('socid'); + $action =GETPOST('action'); + $confirm =GETPOST('confirm'); + $lineid =GETPOST('lineid'); + $userid =GETPOST('userid'); + $search_ref =GETPOST('sf_ref')?GETPOST('sf_ref'):GETPOST('search_ref'); + + // Security check + $fieldid = isset($_GET["ref"])?'facnumber':'rowid'; + if ($user->societe_id) $socid=$user->societe_id; + $result = restrictedArea($user, 'facture', $id,'','','fk_soc',$fieldid); + + $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; $object=new Facture($db); - - // Insert new invoice in database - if ($action == 'add' && $user->rights->facture->creer) - { - $object->socid=GETPOST('socid'); - $db->begin(); + + // Insert new invoice in database + if ($action == 'add' && $user->rights->facture->creer) + { + $object->socid=GETPOST('socid'); + $db->begin(); $error=0; - - // Standard or deposit or proforma invoice - if ($_POST['type'] == 0 ) - { - $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - if (empty($datefacture)) - { - $datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y")); - } - if (! $error) - { - // Si facture standard - $object->socid = $_POST['socid']; - $object->type = $_POST['type']; - $object->number = $_POST['facnumber']; - $object->date = $datefacture; - $object->note_public = trim($_POST['note_public']); - $object->note = trim($_POST['note']); - $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; - $object->modelpdf = $_POST['model']; - $object->fk_project = $_POST['projectid']; - $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); - $object->mode_reglement_id = $_POST['mode_reglement_id']; - $object->amount = $_POST['amount']; - $object->remise_absolue = $_POST['remise_absolue']; - $object->remise_percent = $_POST['remise_percent']; - - if ($_POST['origin'] && $_POST['originid']) + + // Standard or deposit or proforma invoice + if ($_POST['type'] == 0 ) + { + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($datefacture)) + { + $datefacture = dol_mktime(12, 0, 0, date("m"), date("d"), date("Y")); + } + if (! $error) + { + // Si facture standard + $object->socid = $_POST['socid']; + $object->type = $_POST['type']; + $object->number = $_POST['facnumber']; + $object->date = $datefacture; + $object->note_public = trim($_POST['note_public']); + $object->note = trim($_POST['note']); + $object->ref_client = $_POST['ref_client']; + $object->ref_int = $_POST['ref_int']; + $object->modelpdf = $_POST['model']; + $object->fk_project = $_POST['projectid']; + $object->cond_reglement_id = ($_POST['type'] == 3?1:$_POST['cond_reglement_id']); + $object->mode_reglement_id = $_POST['mode_reglement_id']; + $object->amount = $_POST['amount']; + $object->remise_absolue = $_POST['remise_absolue']; + $object->remise_percent = $_POST['remise_percent']; + + if ($_POST['origin'] && $_POST['originid']) { $object->origin = $_POST['origin']; $object->origin_id = $orders_id[$ii]; - $object->linked_objects = $orders_id; + $object->linked_objects = $orders_id; $id = $object->create($user); if ($id>0) { foreach($orders_id as $origin => $origin_id) - { - $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); - $db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; - $sql.= "fk_source"; - $sql.= ", sourcetype"; - $sql.= ", fk_target"; - $sql.= ", targettype"; - $sql.= ") VALUES ("; - $sql.= $origin_id; - $sql.= ", '".$object->origin."'"; - $sql.= ", ".$id; - $sql.= ", '".$object->element."'"; - $sql.= ")"; - - if ($db->query($sql)) - { - $db->commit(); - } - else - { - $db->rollback(); + { + $origin_id = (! empty($origin_id) ? $origin_id : $object->origin_id); + $db->begin(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sql.= "fk_source"; + $sql.= ", sourcetype"; + $sql.= ", fk_target"; + $sql.= ", targettype"; + $sql.= ") VALUES ("; + $sql.= $origin_id; + $sql.= ", '".$object->origin."'"; + $sql.= ", ".$id; + $sql.= ", '".$object->element."'"; + $sql.= ")"; + + if ($db->query($sql)) + { + $db->commit(); } - } - - while ($ii < $nn) - { - dol_include_once('/commande/class/commande.class.php'); - $srcobject = new Commande($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); - $result=$srcobject->fetch($orders_id[$ii]); - if ($result > 0) + else + { + $db->rollback(); + } + } + + while ($ii < $nn) + { + dol_include_once('/commande/class/commande.class.php'); + $srcobject = new Commande($db); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($orders_id[$ii]); + if ($result > 0) { $srcobject->classer_facturee(); - $srcobject->setStatut(3); - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - if ($lines[$i]->subprice < 0) - { - // Negative line, we create a discount line - $discount = new DiscountAbsolute($db); - $discount->fk_soc=$object->socid; - $discount->amount_ht=abs($lines[$i]->total_ht); - $discount->amount_tva=abs($lines[$i]->total_tva); - $discount->amount_ttc=abs($lines[$i]->total_ttc); - $discount->tva_tx=$lines[$i]->tva_tx; - $discount->fk_user=$user->id; - $discount->description=$desc; - $discountid=$discount->create($user); - if ($discountid > 0) - { - $result=$object->insert_discount($discountid); - //$result=$discount->link_to_invoice($lineid,$id); - } - else - { - $mesg=$discount->error; - $error++; - break; - } - } - else - { - // Positive line - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - // Date start - $date_start=false; - if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - //Date end - $date_end=false; - if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; - // Reset fk_parent_line for no child products and special product + $srcobject->setStatut(3); + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + if ($lines[$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc=$object->socid; + $discount->amount_ht=abs($lines[$i]->total_ht); + $discount->amount_tva=abs($lines[$i]->total_tva); + $discount->amount_ttc=abs($lines[$i]->total_ttc); + $discount->tva_tx=$lines[$i]->tva_tx; + $discount->fk_user=$user->id; + $discount->description=$desc; + $discountid=$discount->create($user); + if ($discountid > 0) + { + $result=$object->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } + else + { + $mesg=$discount->error; + $error++; + break; + } + } + else + { + // Positive line + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + // Date start + $date_start=false; + if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + //Date end + $date_end=false; + if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) - { - $fk_parent_line = 0; - } + { + $fk_parent_line = 0; + } $result = $object->addline( - $id, - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - $lines[$i]->fk_remise_except, - 'HT', - 0, - $product_type, - $lines[$i]->rang, - $lines[$i]->special_code, - $object->origin, - $lines[$i]->rowid, - $fk_parent_line - ); - if ($result > 0) - { - $lineid=$result; - } - else - { - $lineid=0; - $error++; - break; - } - // Defined the new fk_parent_line + $id, + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line + ); + if ($result > 0) + { + $lineid=$result; + } + else + { + $lineid=0; + $error++; + break; + } + // Defined the new fk_parent_line if ($result > 0 && $lines[$i]->product_type == 9) - { - $fk_parent_line = $result; - } - } - } - } - else - { - $mesg=$srcobject->error; - $error++; + { + $fk_parent_line = $result; + } + } + } } - $ii++; + else + { + $mesg=$srcobject->error; + $error++; + } + $ii++; } } - else - { - $mesg=$object->error; - $error++; - } - } + else + { + $mesg=$object->error; + $error++; + } + } } } - - // End of object creation, we show it - if ($id > 0 && ! $error) - { - $db->commit(); - Header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$id); - exit; - } - else - { - $db->rollback(); - $action='create'; - $_GET["origin"]=$_POST["origin"]; - $_GET["originid"]=$_POST["originid"]; - if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>'; - } + + // End of object creation, we show it + if ($id > 0 && ! $error) + { + $db->commit(); + Header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$id); + exit; + } + else + { + $db->rollback(); + $action='create'; + $_GET["origin"]=$_POST["origin"]; + $_GET["originid"]=$_POST["originid"]; + if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>'; + } } - - /* - * View - */ - $html = new Form($db); - $htmlother = new FormOther($db); - $formfile = new FormFile($db); - $now=dol_now(); - - // Mode creation - if ($action == 'create') - { - $facturestatic=new Facture($db); - llxHeader(); - print_fiche_titre($langs->trans('NewBill')); - dol_htmloutput_mesg($mesg); - $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); + + /* + * View + */ + $html = new Form($db); + $htmlother = new FormOther($db); + $formfile = new FormFile($db); + $now=dol_now(); + + // Mode creation + if ($action == 'create') + { + $facturestatic=new Facture($db); + llxHeader(); + print_fiche_titre($langs->trans('NewBill')); + dol_htmloutput_mesg($mesg); + $soc = new Societe($db); + if ($socid) $res=$soc->fetch($socid); if ($res) - { - $cond_reglement_id = $soc->cond_reglement_id; - $mode_reglement_id = $soc->mode_reglement_id; + { + $cond_reglement_id = $soc->cond_reglement_id; + $mode_reglement_id = $soc->mode_reglement_id; $remise_percent = $soc->remise_percent; - } - $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - - $absolute_discount=$soc->getAvailableDiscounts(); - print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="action" value="add">'; - print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; - print '<input name="facnumber" type="hidden" value="provisoire">'; - print '<input name="ref_client" type="hidden" value="'.$ref_client.'">'; - print '<input name="ref_int" type="hidden" value="'.$ref_int.'">'; - print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">'; - print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">'; - print '<table class="border" width="100%">'; - // Ref - print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>'; - // Tiers - print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">'; - print $soc->getNomUrl(1); - print '<input type="hidden" name="socid" value="'.$soc->id.'">'; - print '</td>'; - print '</tr>'."\n"; - print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">'; - print '<table class="nobordernopadding">'."\n"; - // Standard invoice - print '<tr height="18"><td width="16px" valign="middle">'; - print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>'; - print '</td><td valign="middle">'; - $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); - print $desc; - print '</td></tr>'."\n"; - print '</table>'; - // Date invoice - print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; - $html->select_date(0,'','','','',"add",1,1); - print '</td></tr>'; - // Payment term - print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; - $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); - print '</td></tr>'; - // Payment mode - print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; - $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); - print '</td></tr>'; - // Project - if ($conf->projet->enabled) - { - $langs->load('projects'); - print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; - select_projects($soc->id, $projectid, 'projectid'); - print '</td></tr>'; - } - // Modele PDF - print '<tr><td>'.$langs->trans('Model').'</td>'; - print '<td>'; + } + $remise_absolue = 0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + + $absolute_discount=$soc->getAvailableDiscounts(); + print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; + print '<input type="hidden" name="action" value="add">'; + print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n"; + print '<input name="facnumber" type="hidden" value="provisoire">'; + print '<input name="ref_client" type="hidden" value="'.$ref_client.'">'; + print '<input name="ref_int" type="hidden" value="'.$ref_int.'">'; + print '<input type="hidden" name="origin" value="'.GETPOST('origin').'">'; + print '<input type="hidden" name="originid" value="'.GETPOST('originid').'">'; + print '<table class="border" width="100%">'; + // Ref + print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>'; + // Tiers + print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">'; + print $soc->getNomUrl(1); + print '<input type="hidden" name="socid" value="'.$soc->id.'">'; + print '</td>'; + print '</tr>'."\n"; + print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">'; + print '<table class="nobordernopadding">'."\n"; + // Standard invoice + print '<tr height="18"><td width="16px" valign="middle">'; + print '<input type="radio" name="type" value="0"'.(GETPOST('type')==0?' checked="true"':'').'>'; + print '</td><td valign="middle">'; + $desc=$html->textwithpicto($langs->trans("InvoiceStandardAsk"),$langs->transnoentities("InvoiceStandardDesc"),1); + print $desc; + print '</td></tr>'."\n"; + print '</table>'; + // Date invoice + print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">'; + $html->select_date(0,'','','','',"add",1,1); + print '</td></tr>'; + // Payment term + print '<tr><td nowrap>'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">'; + $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); + print '</td></tr>'; + // Payment mode + print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; + $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); + print '</td></tr>'; + // Project + if ($conf->projet->enabled) + { + $langs->load('projects'); + print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">'; + select_projects($soc->id, $projectid, 'projectid'); + print '</td></tr>'; + } + // Modele PDF + print '<tr><td>'.$langs->trans('Model').'</td>'; + print '<td>'; include_once(DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'); - $liste=ModelePDFFactures::liste_modeles($db); - print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF); - print "</td></tr>"; - - // Public note - print '<tr>'; - print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>'; - print '<td valign="top" colspan="2">'; + $liste=ModelePDFFactures::liste_modeles($db); + print $html->selectarray('model',$liste,$conf->global->FACTURE_ADDON_PDF); + print "</td></tr>"; + + // Public note + print '<tr>'; + print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>'; + print '<td valign="top" colspan="2">'; print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">'; - dol_include_once('/commande/class/commande.class.php'); - $srcobject = new Commande($db); - $commandes = $langs->trans("Orders").": "; - foreach ($selected as $sel) - { - $result=$srcobject->fetch($sel); - if ($result > 0) - { - $commandes.= $srcobject->ref." "; - } - } + dol_include_once('/commande/class/commande.class.php'); + $srcobject = new Commande($db); + $commandes = $langs->trans("Orders").": "; + foreach ($selected as $sel) + { + $result=$srcobject->fetch($sel); + if ($result > 0) + { + $commandes.= $srcobject->ref." "; + } + } print $commandes; - - print '</textarea></td></tr>'; - // Private note - if (! $user->societe_id) - { - print '<tr>'; - print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>'; - print '<td valign="top" colspan="2">'; - print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; - - print '</textarea></td></tr>'; - } - - print '</table>'; - print '</td></tr>'; - + + print '</textarea></td></tr>'; + // Private note + if (! $user->societe_id) + { + print '<tr>'; + print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>'; + print '<td valign="top" colspan="2">'; + print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">'; + + print '</textarea></td></tr>'; + } + + print '</table>'; + print '</td></tr>'; + } - while ($i < $n) - { - print '<input type="hidden" name="orders_to_invoice[]" value="'.$orders_id[$i].'">'; - - $i++; + while ($i < $n) + { + print '<input type="hidden" name="orders_to_invoice[]" value="'.$orders_id[$i].'">'; + + $i++; } - - print "</table>\n"; - // Button "Create Draft" - print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>'; + + print "</table>\n"; + // Button "Create Draft" + print '<br><center><input type="submit" class="button" name="bouton" value="'.$langs->trans('CreateDraft').'"></center>'; print "</form>\n"; } @@ -513,7 +513,7 @@ else //Date filter if ($date_start && $date_end) $sql.= " AND c.date_commande >= '".$db->idate($date_start)."' AND c.date_commande <= '".$db->idate($date_end)."'"; - if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; + if ($date_starty && $date_endy) $sql.= " AND c.date_livraison >= '".$db->idate($date_starty)."' AND c.date_livraison <= '".$db->idate($date_endy)."'"; if (!empty($sref_client)) { @@ -538,14 +538,14 @@ else $num = $db->num_rows($resql); print_fiche_titre($title); $i = 0; - $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1); + $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1); $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1); - // Company - print '<h3>'; - $companystatic->id=$socid; - $companystatic->nom=$soc->nom; - - print $companystatic->getNomUrl(1,'customer'); + // Company + print '<h3>'; + $companystatic->id=$socid; + $companystatic->nom=$soc->nom; + + print $companystatic->getNomUrl(1,'customer'); print '</h3>'; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; @@ -584,8 +584,8 @@ else print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; //ALL/NONE - print '<td class="liste_titre" align="center">'; - if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; + print '<td class="liste_titre" align="center">'; + if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; print '</td>'; print '</td></tr>'; @@ -625,13 +625,13 @@ else print '<td>'.$objp->ref_client.'</td>'; // Order date - print '<td align="center" nowrap>'; - print dol_print_date($db->jdate($objp->date_commande),'day'); + print '<td align="center" nowrap>'; + print dol_print_date($db->jdate($objp->date_commande),'day'); print '</td>'; //Delivery date - print '<td align="center" nowrap>'; - print dol_print_date($db->jdate($objp->date_livraison),'day'); + print '<td align="center" nowrap>'; + print dol_print_date($db->jdate($objp->date_livraison),'day'); print '</td>'; // Statut @@ -650,15 +650,15 @@ else } print '</table>'; - /* - * Boutons actions + /* + * Boutons actions */ - print '<div align="right">'; - print '<input type="hidden" name="socid" value="'.$socid.'">'; - print '<input type="hidden" name="action" value="create">'; + print '<div align="right">'; + print '<input type="hidden" name="socid" value="'.$socid.'">'; + print '<input type="hidden" name="action" value="create">'; print '<input type="hidden" name="origin" value="commande"><br>'; - print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>'; - print '<input type="submit" class="butAction" value='.$langs->trans("GenerateBill").'>'; + print '<a class="butAction" href="index.php">'.$langs->trans("GoBack").'</a>'; + print '<input type="submit" class="butAction" value='.$langs->trans("GenerateBill").'>'; print '</form>'; $db->free($resql); } diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index cf97fd8ee83d98e23d354c39daa98f297e09c4ca..9e97c88ae1e3782bb20ec0bc0f89584c810ccc25 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -499,8 +499,8 @@ else if ($id) print "</table><br>"; // Notes - $blocname = 'notes'; - $title = $langs->trans('Notes'); + $blocname = 'notes'; + $title = $langs->trans('Notes'); include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); print '</div>'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 6ea8b90fa0165aef8fd9d1cb90b224b63b0bf6e4..ac5c2afde9e49839577bb166142e726d487a2e57 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -69,7 +69,7 @@ $search_societe=GETPOST('search_societe','alpha'); $search_montant_ht=GETPOST('search_montant_ht','alpha'); $search_montant_ttc=GETPOST('search_montant_ttc','alpha'); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -86,10 +86,10 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; $object=new Facture($db); -// Load object -if ($id > 0 || ! empty($ref)) -{ - $ret=$object->fetch($id, $ref); +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -1524,21 +1524,21 @@ else if ($action == 'builddoc') // En get ou en post } } -// Remove file in doc form -else if ($action == 'remove_file') -{ - if ($object->fetch($id)) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $object->fetch_thirdparty(); - - $langs->load("other"); - $upload_dir = $conf->facture->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file,0,0,0,$object); - $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; - } +// Remove file in doc form +else if ($action == 'remove_file') +{ + if ($object->fetch($id)) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->facture->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; + } } if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e8ecfaf74b5dacd3587275844b507282ae24637d..4842d8f5079be67c5fdc7191c5b81b06ee4c80a5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -256,30 +256,30 @@ class Facture extends CommonObject $error++; } - // TODO mutualiser - if ($origin == 'commande') - { - // On recupere les differents contact interne et externe + // TODO mutualiser + if ($origin == 'commande') + { + // On recupere les differents contact interne et externe $order = new Commande($this->db); - $order->id = $origin_id; - - // On recupere le commercial suivi propale + $order->id = $origin_id; + + // On recupere le commercial suivi propale $this->userid = $order->getIdcontact('internal', 'SALESREPFOLL'); - - if ($this->userid) - { - //On passe le commercial suivi commande en commercial suivi paiement - $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); - } - - // On recupere le contact client facturation commande - $this->contactid = $order->getIdcontact('external', 'BILLING'); - - if ($this->contactid) - { - //On passe le contact client facturation commande en contact client facturation - $this->add_contact($this->contactid[0], 'BILLING', 'external'); - } + + if ($this->userid) + { + //On passe le commercial suivi commande en commercial suivi paiement + $this->add_contact($this->userid[0], 'SALESREPFOLL', 'internal'); + } + + // On recupere le contact client facturation commande + $this->contactid = $order->getIdcontact('external', 'BILLING'); + + if ($this->contactid) + { + //On passe le contact client facturation commande en contact client facturation + $this->add_contact($this->contactid[0], 'BILLING', 'external'); + } } } } @@ -674,11 +674,11 @@ class Facture extends CommonObject $this->origin = $object->element; $this->origin_id = $object->id; - // Possibility to add external linked objects with hooks - $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) - { - $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); + // Possibility to add external linked objects with hooks + $this->linked_objects[$this->origin] = $this->origin_id; + if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + { + $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } $ret = $this->create($user); @@ -1240,32 +1240,32 @@ class Facture extends CommonObject $resql=$this->db->query($sql); if ($resql) { - // On efface le repertoire de pdf provisoire - $ref = dol_sanitizeFileName($this->ref); - if ($conf->facture->dir_output) - { - $dir = $conf->facture->dir_output . "/" . $ref; - $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; - if (file_exists($file)) // We must delete all files before deleting directory - { + // On efface le repertoire de pdf provisoire + $ref = dol_sanitizeFileName($this->ref); + if ($conf->facture->dir_output) + { + $dir = $conf->facture->dir_output . "/" . $ref; + $file = $conf->facture->dir_output . "/" . $ref . "/" . $ref . ".pdf"; + if (file_exists($file)) // We must delete all files before deleting directory + { $ret=dol_delete_preview($this); - - if (! dol_delete_file($file,0,0,0,$this)) // For triggers - { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - $this->db->rollback(); - return 0; - } - } - if (file_exists($dir)) - { - if (! dol_delete_dir_recursive($dir)) // For remove dir and meta - { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - $this->db->rollback(); - return 0; - } - } + + if (! dol_delete_file($file,0,0,0,$this)) // For triggers + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + $this->db->rollback(); + return 0; + } + } + if (file_exists($dir)) + { + if (! dol_delete_dir_recursive($dir)) // For remove dir and meta + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + $this->db->rollback(); + return 0; + } + } } $this->db->commit(); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index bdb0990f4b37aba6e9d733e893f1a9f57671364b..7a789c32c4fa62ecebccf337ee4759554e2de119 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -43,11 +43,11 @@ $confirm = GETPOST('confirm'); $id = GETPOST('facid','int'); $ref = GETPOST('ref'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index c2258ea78f89c62a29b59fac78ae03308986c436..c68ad3777d84a045556f110986992a3f3d8d6445 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -31,9 +31,9 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'); $langs->load("companies"); $langs->load("bills"); -$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility -$ref=GETPOST('ref','alpha'); -$socid=GETPOST('socid','int'); +$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); $action=GETPOST('action','alpha'); // Security check diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 5f343fd8944e3010fa6c9efa700addaadaa0dfd8..2bdfc30a440cf8985ec765662c1d5ab698b1c841 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -791,35 +791,35 @@ class Contrat extends CommonObject } } - if (! $error) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers } - if (! $error) - { - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->contrat->dir_output) - { - $dir = $conf->contrat->dir_output . "/" . $ref; - if (file_exists($dir)) - { - $res=@dol_delete_dir_recursive($dir); - if (! $res) - { - $this->error='ErrorFailToDeleteDir'; - $error++; - } - } - } + if (! $error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->contrat->dir_output) + { + $dir = $conf->contrat->dir_output . "/" . $ref; + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $error++; + } + } + } } if (! $error) diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 7a35a414481c33011967e36da6c28bd03a57bd78..915a2775b91101c6f04762647f3e88eb8cf33c22 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -168,9 +168,9 @@ if ($id > 0 || ! empty($ref)) print '</div>'; - print '<br>'; - - // Contacts lines + print '<br>'; + + // Contacts lines include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php'); } diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index a16030a686bf9662ae35ac76a34f6af201343224..298fdd0da4e502073f460a46d7a0a3f71d5b7ed3 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -36,16 +36,16 @@ $langs->load("other"); $langs->load("products"); -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); +$id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -120,19 +120,19 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } -// Delete -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id) - { - $langs->load("other"); - - $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $ret=dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } +// Delete +if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id) + { + $langs->load("other"); + + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $ret=dol_delete_file($file,0,0,0,$object); + $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } } @@ -178,13 +178,13 @@ if ($object->id) dol_htmloutput_mesg($mesg,$mesgs); - /* + /* * Confirmation suppression fichier - */ - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); - if ($ret == 'html') print '<br>'; + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '<br>'; } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 3e26e4c9b88c4df8f9cf009f622119bac3d64e0b..4474f56ea05e89480814b4714b348cfe1795b073 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -428,113 +428,113 @@ else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contr else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { $object->fetch($id); - $object->fetch_thirdparty(); - $result=$object->delete($user); - if ($result >= 0) - { - Header("Location: index.php"); - return; - } - else - { - $mesg='<div class="error">'.$object->error.'</div>'; + $object->fetch_thirdparty(); + $result=$object->delete($user); + if ($result >= 0) + { + Header("Location: index.php"); + return; + } + else + { + $mesg='<div class="error">'.$object->error.'</div>'; } } else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { - if ($_POST['newcid'] > 0) - { - $contractline = new ContratLigne($db); - $result=$contractline->fetch($_GET["lineid"]); - $contractline->fk_contrat = $_POST["newcid"]; - $result=$contractline->update($user,1); - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - return; - } - else - { - $mesg='<div class="error">'.$object->error.'</div>'; - } - } - else - { - $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'</div>'; + if ($_POST['newcid'] > 0) + { + $contractline = new ContratLigne($db); + $result=$contractline->fetch($_GET["lineid"]); + $contractline->fk_contrat = $_POST["newcid"]; + $result=$contractline->update($user,1); + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + return; + } + else + { + $mesg='<div class="error">'.$object->error.'</div>'; + } + } + else + { + $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("RefNewContract")).'</div>'; } } -else if ($action == 'setnote_public' && $user->rights->contrat->creer) -{ - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->contrat->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); +else if ($action == 'setnote_public' && $user->rights->contrat->creer) +{ + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->contrat->creer) +{ + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->contrat->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->contrat->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; - } - else - { - $mesg = '<div class="error">'.$object->error.'</div>'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->contrat->creer) - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->contrat->creer) - { - $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; + } + else + { + $mesg = '<div class="error">'.$object->error.'</div>'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->contrat->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->contrat->creer) + { + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } } } @@ -783,21 +783,21 @@ else echo '<br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index 0855fc6ec291d094d2e19671407837cb5a7cc6b6..57bd23ccd89b18a19f7645e04cc69ff3cb27eefe 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -30,9 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); $langs->load("companies"); $langs->load("contracts"); -$action=GETPOST('action','alpha'); -$confirm=GETPOST('confirm','alpha'); -$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$socid=GETPOST('socid','int'); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index a3a525d0d3c31e1e5791229307d375b99fd00c8c..30c52242f74cb89a7a93c2ae9ad0e5df66fc9224 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -57,7 +57,7 @@ header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE'); header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); switch ($_SERVER['REQUEST_METHOD']) { - case 'OPTIONS': + case 'OPTIONS': break; case 'HEAD': case 'GET': diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 55d9adb70f3499d416e5054538a5d272a99b340f..45781e4637949efd0c05c6301701c02efd895c8e 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -90,7 +90,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ $module = $subelement = $ext_element; if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) { - $module = $regs[1]; + $module = $regs[1]; $subelement = $regs[2]; } diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 50541facffa78c629878dc862e4ade9c4ba1eb67..04cb8955a8a902dc7f8cbaf1ed35c4bf2738d568 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -30,9 +30,9 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php"); -$field = GETPOST('field','alpha',2); -$element = GETPOST('element','alpha',2); -$table_element = GETPOST('table_element','alpha',2); +$field = GETPOST('field','alpha',2); +$element = GETPOST('element','alpha',2); +$table_element = GETPOST('table_element','alpha',2); $fk_element = GETPOST('fk_element','alpha',2); /* @@ -132,11 +132,11 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else { - $module = $subelement = $ext_element; - if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) - { - $module = $regs[1]; - $subelement = $regs[2]; + $module = $subelement = $ext_element; + if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) + { + $module = $regs[1]; + $subelement = $regs[2]; } dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index c4ecc36ae9b3181c7184771df9fdf685df43347c..985cfb9b71bed9ab1b99147ee304c239bc64be24 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -49,12 +49,12 @@ if (! empty($id) && ! empty($action) && ! empty($htmlname)) $soc->fetch($id); - $return=array(); - - $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); - $return['num'] = $form->num; - $return['error'] = $form->error; - + $return=array(); + + $return['value'] = $form->load_tva('tva_tx','',$soc,$mysoc,0,0,'',true); + $return['num'] = $form->num; + $return['error'] = $form->error; + echo json_encode($return); } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 32f4634e40e148eba0929b01199c5e76d75da0ba..a216383b9d5b0d316b57de4d4c0874fba680bf99 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -206,28 +206,28 @@ class Conf //var_dump($this->modules); //var_dump($this->modules_parts); - // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) - { - global $mc; - $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); - if ($ret) $mc = new ActionsMulticompany($db); + // Object $mc + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) + { + global $mc; + $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); + if ($ret) $mc = new ActionsMulticompany($db); } // Second or others levels object - $this->propal->cloture = (object) array(); + $this->propal->cloture = (object) array(); $this->propal->facturation = (object) array(); - $this->commande->client = (object) array(); + $this->commande->client = (object) array(); $this->commande->fournisseur = (object) array(); - $this->facture->client = (object) array(); + $this->facture->client = (object) array(); $this->facture->fournisseur = (object) array(); - $this->fournisseur->commande = (object) array(); + $this->fournisseur->commande = (object) array(); $this->fournisseur->facture = (object) array(); - $this->contrat->services = (object) array(); - $this->contrat->services->inactifs = (object) array(); + $this->contrat->services = (object) array(); + $this->contrat->services->inactifs = (object) array(); $this->contrat->services->expires = (object) array(); $this->adherent->cotisation = (object) array(); - $this->bank->rappro = (object) array(); + $this->bank->rappro = (object) array(); $this->bank->cheque = (object) array(); // Clean some variables @@ -261,7 +261,7 @@ class Conf // Define default dir_output and dir_temp for directories of modules foreach($this->modules as $module) { - $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); + $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); // For backward compatibility $this->$module->dir_output = $rootfordata."/".$module; @@ -277,14 +277,14 @@ class Conf $this->admin->dir_temp=$rootfordata.'/admin/temp'; // For user storage - $this->user->multidir_output = array($this->entity => $rootfordata."/users"); + $this->user->multidir_output = array($this->entity => $rootfordata."/users"); $this->user->multidir_temp = array($this->entity => $rootfordata."/users/temp"); // For backward compatibility $this->user->dir_output=$rootforuser."/users"; $this->user->dir_temp=$rootforuser."/users/temp"; - // For propal storage - $this->propal->dir_output=$rootforuser."/propale"; + // For propal storage + $this->propal->dir_output=$rootforuser."/propale"; $this->propal->dir_temp=$rootforuser."/propale/temp"; // Exception: Some dir are not the name of module. So we keep exception here @@ -307,9 +307,9 @@ class Conf $this->service->multidir_output=array($this->entity => $rootfordata."/produit"); $this->service->multidir_temp =array($this->entity => $rootfordata."/produit/temp"); // For backward compatibility - $this->product->dir_output=$rootfordata."/produit"; - $this->product->dir_temp =$rootfordata."/produit/temp"; - $this->service->dir_output=$rootfordata."/produit"; + $this->product->dir_output=$rootfordata."/produit"; + $this->product->dir_temp =$rootfordata."/produit/temp"; + $this->service->dir_output=$rootfordata."/produit"; $this->service->dir_temp =$rootfordata."/produit/temp"; // Module contrat @@ -429,10 +429,10 @@ class Conf if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; - // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) + // Object $mc + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) { - if (is_object($mc)) $mc->setValues($this); + if (is_object($mc)) $mc->setValues($this); } } } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 3fff8b7667c9bb2e85d37a144c4c1f7355661f00..50b699d8b33e46fb3b248c4012ef094e44d0c1ea 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -65,9 +65,9 @@ class FileUpload $pathname = 'compta/facture'; $dir_output=$conf->$element->dir_output; } - elseif ($element == 'project') { + elseif ($element == 'project') { $element = $pathname = 'projet'; - $dir_output=$conf->$element->dir_output; + $dir_output=$conf->$element->dir_output; } elseif ($element == 'fichinter') { $element='ficheinter'; @@ -108,11 +108,11 @@ class FileUpload 'accept_file_types' => '/.+$/i', // The maximum number of files for the upload directory: 'max_number_of_files' => null, - // Image resolution restrictions: - 'max_width' => null, - 'max_height' => null, - 'min_width' => 1, - 'min_height' => 1, + // Image resolution restrictions: + 'max_width' => null, + 'max_height' => null, + 'min_width' => 1, + 'min_height' => 1, // Set the following option to false to enable resumable uploads: 'discard_aborted_uploads' => true, 'image_versions' => array( @@ -131,7 +131,7 @@ class FileUpload 'thumbnail' => array( 'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/', - 'max_width' => 80, + 'max_width' => 80, 'max_height' => 80 ) ) @@ -148,14 +148,14 @@ class FileUpload */ protected function getFullUrl() { - $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; - return - ($https ? 'https://' : 'http://'). - (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). - (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. - ($https && $_SERVER['SERVER_PORT'] === 443 || - $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). - substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); + $https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; + return + ($https ? 'https://' : 'http://'). + (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). + (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. + ($https && $_SERVER['SERVER_PORT'] === 443 || + $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). + substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); } /** @@ -165,13 +165,13 @@ class FileUpload * @return void */ protected function setFileDeleteUrl($file) - { - $file->delete_url = $this->options['script_url'] - .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; - $file->delete_type = $this->options['delete_type']; - if ($file->delete_type !== 'DELETE') { - $file->delete_url .= '&_method=DELETE'; - } + { + $file->delete_url = $this->options['script_url'] + .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; + $file->delete_type = $this->options['delete_type']; + if ($file->delete_type !== 'DELETE') { + $file->delete_url .= '&_method=DELETE'; + } } /** @@ -260,9 +260,9 @@ class FileUpload $file->error = $error; return false; } - if (!$file->name) { - $file->error = 'missingFileName'; - return false; + if (!$file->name) { + $file->error = 'missingFileName'; + return false; } if (!preg_match($this->options['accept_file_types'], $file->name)) { $file->error = 'acceptFileTypes'; @@ -314,10 +314,10 @@ class FileUpload * @return string ??? */ protected function upcountNameCallback($matches) - { - $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; - $ext = isset($matches[2]) ? $matches[2] : ''; - return ' ('.$index.')'.$ext; + { + $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; + $ext = isset($matches[2]) ? $matches[2] : ''; + return ' ('.$index.')'.$ext; } /** @@ -327,8 +327,8 @@ class FileUpload * @return string ??? */ protected function upcountName($name) - { - return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1); + { + return preg_replace_callback('/(?:(?: \(([\d]+)\))?(\.[^.]+))?$/', array($this, 'upcountNameCallback'), $name, 1); } /** @@ -340,24 +340,24 @@ class FileUpload * @return void */ protected function trimFileName($name, $type, $index) - { - // Remove path information and dots around the filename, to prevent uploading - // into different directories or replacing hidden system files. - // Also remove control characters and spaces (\x00..\x20) around the filename: - $file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); - // Add missing file extension for known image types: - if (strpos($file_name, '.') === false && - preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { - $file_name .= '.'.$matches[1]; - } + { + // Remove path information and dots around the filename, to prevent uploading + // into different directories or replacing hidden system files. + // Also remove control characters and spaces (\x00..\x20) around the filename: + $file_name = trim(basename(stripslashes($name)), ".\x00..\x20"); + // Add missing file extension for known image types: + if (strpos($file_name, '.') === false && + preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { + $file_name .= '.'.$matches[1]; + } if ($this->options['discard_aborted_uploads']) - { + { while(is_file($this->options['upload_dir'].$file_name)) - { - $file_name = $this->upcountName($file_name); - } - } - return $file_name; + { + $file_name = $this->upcountName($file_name); + } + } + return $file_name; } /** @@ -367,33 +367,33 @@ class FileUpload * @return int Success or not */ protected function orientImage($file_path) - { - $exif = @exif_read_data($file_path); - if ($exif === false) { - return false; - } - $orientation = intval(@$exif['Orientation']); - if (!in_array($orientation, array(3, 6, 8))) { - return false; - } - $image = @imagecreatefromjpeg($file_path); - switch ($orientation) { - case 3: - $image = @imagerotate($image, 180, 0); - break; - case 6: - $image = @imagerotate($image, 270, 0); - break; - case 8: - $image = @imagerotate($image, 90, 0); - break; - default: - return false; - } - $success = imagejpeg($image, $file_path); - // Free up memory (imagedestroy does not delete files): - @imagedestroy($image); - return $success; + { + $exif = @exif_read_data($file_path); + if ($exif === false) { + return false; + } + $orientation = intval(@$exif['Orientation']); + if (!in_array($orientation, array(3, 6, 8))) { + return false; + } + $image = @imagecreatefromjpeg($file_path); + switch ($orientation) { + case 3: + $image = @imagerotate($image, 180, 0); + break; + case 6: + $image = @imagerotate($image, 270, 0); + break; + case 8: + $image = @imagerotate($image, 90, 0); + break; + default: + return false; + } + $success = imagejpeg($image, $file_path); + // Free up memory (imagedestroy does not delete files): + @imagedestroy($image); + return $success; } /** @@ -416,40 +416,40 @@ class FileUpload $file->type = $type; if ($this->validate($uploaded_file, $file, $error, $index) && dol_mkdir($this->options['upload_dir']) >= 0) { - $file_path = $this->options['upload_dir'].$file->name; - $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); + $file_path = $this->options['upload_dir'].$file->name; + $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path); clearstatcache(); - if ($uploaded_file && is_uploaded_file($uploaded_file)) { - // multipart/formdata uploads (POST method uploads) + if ($uploaded_file && is_uploaded_file($uploaded_file)) { + // multipart/formdata uploads (POST method uploads) if ($append_file) - { - file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); - } else { - dol_move_uploaded_file($uploaded_file, $file_path, 1); - } + { + file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND); + } else { + dol_move_uploaded_file($uploaded_file, $file_path, 1); + } } else - { - // Non-multipart uploads (PUT method support) - file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); - } + { + // Non-multipart uploads (PUT method support) + file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0); + } $file_size = filesize($file_path); if ($file_size === $file->size) - { - $file->url = $this->options['upload_url'].rawurlencode($file->name); - foreach($this->options['image_versions'] as $version => $options) - { - if ($this->createScaledImage($file->name, $options)) - { - $tmp=explode('.',$file->name); - $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); - } - } + { + $file->url = $this->options['upload_url'].rawurlencode($file->name); + foreach($this->options['image_versions'] as $version => $options) + { + if ($this->createScaledImage($file->name, $options)) + { + $tmp=explode('.',$file->name); + $file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]); + } + } } else if ($this->options['discard_aborted_uploads']) - { - unlink($file_path); - $file->error = 'abort'; + { + unlink($file_path); + $file->error = 'abort'; } $file->size = $file_size; $this->setFileDeleteUrl($file); @@ -486,15 +486,15 @@ class FileUpload public function post() { if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') - { - return $this->delete(); + { + return $this->delete(); } $upload = isset($_FILES[$this->options['param_name']]) ? $_FILES[$this->options['param_name']] : null; $info = array(); if ($upload && is_array($upload['tmp_name'])) { - // param_name is an array identifier like "files[]", + // param_name is an array identifier like "files[]", // $_FILES is a multi-dimensional array: foreach ($upload['tmp_name'] as $index => $value) { $info[] = $this->handleFileUpload( @@ -507,7 +507,7 @@ class FileUpload ); } } elseif ($upload || isset($_SERVER['HTTP_X_FILE_NAME'])) { - // param_name is a single object identifier like "file", + // param_name is a single object identifier like "file", // $_FILES is a one-dimensional array: $info[] = $this->handleFileUpload( isset($upload['tmp_name']) ? $upload['tmp_name'] : null, @@ -519,11 +519,11 @@ class FileUpload } header('Vary: Accept'); $json = json_encode($info); - $redirect = isset($_REQUEST['redirect']) ? - stripslashes($_REQUEST['redirect']) : null; - if ($redirect) { - header('Location: '.sprintf($redirect, rawurlencode($json))); - return; + $redirect = isset($_REQUEST['redirect']) ? + stripslashes($_REQUEST['redirect']) : null; + if ($redirect) { + header('Location: '.sprintf($redirect, rawurlencode($json))); + return; } if (isset($_SERVER['HTTP_ACCEPT']) && (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6b8e3469d34662508a27f2667e6ae0bcf61a8b33..595f1eba0d8d2fe2c5cd5506fea5ae9949f56092 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -285,12 +285,12 @@ class Form if (! empty($tmp[2])) $savemethod=$tmp[2]; if (! empty($tmp[3])) $button_only=true; } - else if (preg_match('/^textarea/',$inputType)) - { - $tmp=explode(':',$inputType); + else if (preg_match('/^textarea/',$inputType)) + { + $tmp=explode(':',$inputType); $inputType=$tmp[0]; - if (! empty($tmp[1])) $rows=$tmp[1]; - if (! empty($tmp[2])) $cols=$tmp[2]; + if (! empty($tmp[1])) $rows=$tmp[1]; + if (! empty($tmp[2])) $cols=$tmp[2]; } else if (preg_match('/^ckeditor/',$inputType)) { @@ -790,20 +790,20 @@ class Form } } - /** - * Return list of all contacts (for a third party or all) - * - * @param int $socid Id ot third party or 0 for all - * @param string $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $showempty 0=no empty value, 1=add an empty value - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param string $showfunction Add function into label - * @param string $moreclass Add more class to class style - * @return int <0 if KO, Nb of contact in list if OK - */ - function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') + /** + * Return list of all contacts (for a third party or all) + * + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $showempty 0=no empty value, 1=add an empty value + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param string $showfunction Add function into label + * @param string $moreclass Add more class to class style + * @return int <0 if KO, Nb of contact in list if OK + */ + function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='') { print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass); return $this->num; @@ -2725,50 +2725,50 @@ class Form print $this->selectcurrency($selected,$htmlname); } - /** - * Load into the cache all currencies - * - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO - */ - function load_cache_currencies() - { + /** + * Load into the cache all currencies + * + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + */ + function load_cache_currencies() + { global $langs; - $langs->load("dict"); - - if (count($this->cache_currencies)) return 0; // Cache deja charge - + $langs->load("dict"); + + if (count($this->cache_currencies)) return 0; // Cache deja charge + $sql = "SELECT code_iso, label, unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE active = 1"; $sql.= " ORDER BY code_iso ASC"; - - dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); + + dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:'')); $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true); $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label']; - $i++; + $i++; } array_multisort($label, SORT_ASC, $this->cache_currencies); - - return $num; - } - else - { - dol_print_error($this->db); - return -1; - } + + return $num; + } + else + { + dol_print_error($this->db); + return -1; + } } /** @@ -2833,33 +2833,33 @@ class Form print $this->load_tva($htmlname, $selectedrate, $societe_vendeuse, $societe_acheteuse, $idprod, $info_bits, $type); } - /** + /** * Load into the cache vat rates of a country * - * @param string $country_code Country code - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + * @param string $country_code Country code + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function load_cache_vatrates($country_code) + function load_cache_vatrates($country_code) { global $langs; - $num = count($this->cache_vatrates); + $num = count($this->cache_vatrates); if ($num > 0) return $num; // Cache deja charge - $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql.= " WHERE t.fk_pays = p.rowid"; - $sql.= " AND t.active = 1"; - $sql.= " AND p.code IN (".$country_code.")"; - $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; - - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) + $sql = "SELECT DISTINCT t.taux, t.recuperableonly"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; + $sql.= " WHERE t.fk_pays = p.rowid"; + $sql.= " AND t.active = 1"; + $sql.= " AND p.code IN (".$country_code.")"; + $sql.= " ORDER BY t.taux ASC, t.recuperableonly ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + if ($num) + { + for ($i = 0; $i < $num; $i++) { $obj = $this->db->fetch_object($resql); $this->cache_vatrates[$i]['txtva'] = $obj->taux; @@ -2879,7 +2879,7 @@ class Form { $this->error = '<font class="error">'.$this->db->error().'</font>'; return -2; - } + } } /** @@ -2975,32 +2975,32 @@ class Form if ($num > 0) { - // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') - if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) - { - $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); - $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); - } - - // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. - // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant - if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) - { - $defaulttx = $this->cache_vatrates[$num-1]['txtva']; + // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') + if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) + { + $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); + $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); + } + + // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. + // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant + if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) + { + $defaulttx = $this->cache_vatrates[$num-1]['txtva']; } if (! $options_only) $return.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; foreach ($this->cache_vatrates as $rate) { - $return.= '<option value="'.$rate['txtva']; - $return.= $rate['nprtva'] ? '*': ''; + $return.= '<option value="'.$rate['txtva']; + $return.= $rate['nprtva'] ? '*': ''; $return.= '"'; if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) { $return.= ' selected="selected"'; - } - $return.= '>'.vatrate($rate['libtva']); + } + $return.= '>'.vatrate($rate['libtva']); $return.= $rate['nprtva'] ? ' *': ''; $return.= '</option>'; @@ -3391,79 +3391,79 @@ class Form return $out; } - /** - * Show a multiselect form from an array. - * + /** + * Show a multiselect form from an array. + * * @param string $htmlname Name of select - * @param array $array Array with key+value + * @param array $array Array with key+value * @param array $selected Preselected keys * @param int $key_in_label 1 pour afficher la key dans la valeur "[key] value" * @param int $value_as_key 1 to use value as key * @param string $option Valeur de l'option en fonction du type choisi - * @param int $translate Translate and encode value - * @return string HTML multiselect string - */ - function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0) - { + * @param int $translate Translate and encode value + * @return string HTML multiselect string + */ + function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $option='', $translate=0) + { global $conf, $langs; - - $out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n"; - if (is_array($array) && ! empty($array)) + + $out = '<select id="'.$htmlname.'" class="multiselect" multiple="multiple" name="'.$htmlname.'[]"'.$option.'>'."\n"; + if (is_array($array) && ! empty($array)) { if ($value_as_key) $array=array_combine($array, $array); - if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected)) + if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && is_array($selected) && ! empty($selected)) { foreach ($selected as $selected_value) { foreach($array as $key => $value) { - if ($selected_value == $key) - { - $value=$array[$selected_value]; - $out.= '<option value="'.$key.'" selected="selected">'; - $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); - $newval = ($key_in_label ? $key.' - '.$newval : $newval); - $out.= dol_htmlentitiesbr($newval); - $out.= '</option>'."\n"; - unset($array[$key]); + if ($selected_value == $key) + { + $value=$array[$selected_value]; + $out.= '<option value="'.$key.'" selected="selected">'; + $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); + $newval = ($key_in_label ? $key.' - '.$newval : $newval); + $out.= dol_htmlentitiesbr($newval); + $out.= '</option>'."\n"; + unset($array[$key]); } } } if (! empty($array)) { - foreach ($array as $key => $value) + foreach ($array as $key => $value) { - $out.= '<option value="'.$key.'">'; - $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); - $newval = ($key_in_label ? $key.' - '.$newval : $newval); - $out.= dol_htmlentitiesbr($newval); - $out.= '</option>'."\n"; + $out.= '<option value="'.$key.'">'; + $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); + $newval = ($key_in_label ? $key.' - '.$newval : $newval); + $out.= dol_htmlentitiesbr($newval); + $out.= '</option>'."\n"; } } } else { - foreach ($array as $key => $value) - { - $out.= '<option value="'.$key.'"'; - if (is_array($selected) && ! empty($selected) && in_array($key, $selected)) - { - $out.= ' selected="selected"'; - } - $out.= '>'; - - $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); - $newval = ($key_in_label ? $key.' - '.$newval : $newval); - $out.= dol_htmlentitiesbr($newval); - $out.= '</option>'."\n"; + foreach ($array as $key => $value) + { + $out.= '<option value="'.$key.'"'; + if (is_array($selected) && ! empty($selected) && in_array($key, $selected)) + { + $out.= ' selected="selected"'; + } + $out.= '>'; + + $newval = ($translate ? $langs->trans(ucfirst($value)) : $value); + $newval = ($key_in_label ? $key.' - '.$newval : $newval); + $out.= dol_htmlentitiesbr($newval); + $out.= '</option>'."\n"; } - } - } - $out.= '</select>'."\n"; - - return $out; + } + } + $out.= '</select>'."\n"; + + return $out; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 50acedcac24a312c23e3f009b848c26395d6c706..41508534847c05ac7c0e599d8f59a2a01ce3b150 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -813,7 +813,7 @@ class FormFile // Max file size $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize); - // Include main + // Include main include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/fileupload_main.tpl.php'); // Include template diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 5398825a044dee2f9d6a0d1fbdd20d1feaece0a6..f65f8131ee05f6e8557eecce1c0df61e1a29d54f 100755 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -170,9 +170,9 @@ class SMTPs */ var $_smtpsRelatedBoundary = null; - /** - * Alternative Boundary - */ + /** + * Alternative Boundary + */ var $_smtpsAlternativeBoundary = null; /** @@ -1223,8 +1223,8 @@ class SMTPs if (key_exists('image', $this->_msgContent)) { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; - $content .= "\r\n"; + $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "\r\n"; $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; } @@ -1268,21 +1268,21 @@ class SMTPs . $_data['data'] . "\r\n"; } - // always end related and end alternative after inline images - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; + // always end related and end alternative after inline images + $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; + $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; $content.= "\r\n"; } else { - if (key_exists('image', $this->_msgContent)) - { - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; - $content.= "\r\n"; - $content.= "--" . $this->_getBoundary('related') . "\r\n"; + if (key_exists('image', $this->_msgContent)) + { + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; + $content.= "\r\n" . strip_tags($_content['data']) . "\r\n"; // Add plain text message + $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; + $content.= "\r\n"; + $content.= "--" . $this->_getBoundary('related') . "\r\n"; } $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' @@ -1490,7 +1490,7 @@ class SMTPs function _setBoundary() { $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; - $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2")); + $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2")); $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3")); } diff --git a/htdocs/core/filemanagerdol/browser/default/js/common.js b/htdocs/core/filemanagerdol/browser/default/js/common.js index 98c4b90709500de05b3e3e675ddf630076de24ea..93c520609adfc9a2208078376e25ae018a3c6763 100755 --- a/htdocs/core/filemanagerdol/browser/default/js/common.js +++ b/htdocs/core/filemanagerdol/browser/default/js/common.js @@ -1,88 +1,88 @@ -/* - * FCKeditor - The text editor for Internet - http://www.fckeditor.net - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * == BEGIN LICENSE == - * - * Licensed under the terms of any of the following licenses at your - * choice: - * - * - GNU General Public License Version 2 or later (the "GPL") - * http://www.gnu.org/licenses/gpl.html - * - * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") - * http://www.gnu.org/licenses/lgpl.html - * - * - Mozilla Public License Version 1.1 or later (the "MPL") - * http://www.mozilla.org/MPL/MPL-1.1.html - * - * == END LICENSE == - * - * Common objects and functions shared by all pages that compose the - * File Browser dialog window. - */ - -// Automatically detect the correct document.domain (#1919). -(function() -{ - var d = document.domain ; - - while ( true ) - { - // Test if we can access a parent property. - try - { - var test = window.top.opener.document.domain ; - break ; - } - catch( e ) - {} - - // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... - d = d.replace( /.*?(?:\.|$)/, '' ) ; - - if ( d.length == 0 ) - break ; // It was not able to detect the domain. - - try - { - document.domain = d ; - } - catch (e) - { - break ; - } - } -})() ; - -function AddSelectOption( selectElement, optionText, optionValue ) -{ - var oOption = document.createElement("OPTION") ; - - oOption.text = optionText ; - oOption.value = optionValue ; - - selectElement.options.add(oOption) ; - - return oOption ; -} - -var oConnector = window.parent.oConnector ; -var oIcons = window.parent.oIcons ; - - -function StringBuilder( value ) -{ - this._Strings = new Array( value || '' ) ; -} - -StringBuilder.prototype.Append = function( value ) -{ - if ( value ) - this._Strings.push( value ) ; -} - -StringBuilder.prototype.ToString = function() -{ - return this._Strings.join( '' ) ; -} +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Common objects and functions shared by all pages that compose the + * File Browser dialog window. + */ + +// Automatically detect the correct document.domain (#1919). +(function() +{ + var d = document.domain ; + + while ( true ) + { + // Test if we can access a parent property. + try + { + var test = window.top.opener.document.domain ; + break ; + } + catch( e ) + {} + + // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... + d = d.replace( /.*?(?:\.|$)/, '' ) ; + + if ( d.length == 0 ) + break ; // It was not able to detect the domain. + + try + { + document.domain = d ; + } + catch (e) + { + break ; + } + } +})() ; + +function AddSelectOption( selectElement, optionText, optionValue ) +{ + var oOption = document.createElement("OPTION") ; + + oOption.text = optionText ; + oOption.value = optionValue ; + + selectElement.options.add(oOption) ; + + return oOption ; +} + +var oConnector = window.parent.oConnector ; +var oIcons = window.parent.oIcons ; + + +function StringBuilder( value ) +{ + this._Strings = new Array( value || '' ) ; +} + +StringBuilder.prototype.Append = function( value ) +{ + if ( value ) + this._Strings.push( value ) ; +} + +StringBuilder.prototype.ToString = function() +{ + return this._Strings.join( '' ) ; +} diff --git a/htdocs/core/filemanagerdol/browser/default/js/fckxml.js b/htdocs/core/filemanagerdol/browser/default/js/fckxml.js index b7eddc601e017cc72ddcd0aa66e071bb23776104..d10561d6d866b98b00dcc94494afdc7b2c82d04e 100755 --- a/htdocs/core/filemanagerdol/browser/default/js/fckxml.js +++ b/htdocs/core/filemanagerdol/browser/default/js/fckxml.js @@ -1,147 +1,147 @@ -/* - * FCKeditor - The text editor for Internet - http://www.fckeditor.net - * Copyright (C) 2003-2010 Frederico Caldeira Knabben - * - * == BEGIN LICENSE == - * - * Licensed under the terms of any of the following licenses at your - * choice: - * - * - GNU General Public License Version 2 or later (the "GPL") - * http://www.gnu.org/licenses/gpl.html - * - * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") - * http://www.gnu.org/licenses/lgpl.html - * - * - Mozilla Public License Version 1.1 or later (the "MPL") - * http://www.mozilla.org/MPL/MPL-1.1.html - * - * == END LICENSE == - * - * Defines the FCKXml object that is used for XML data calls - * and XML processing. - * - * This script is shared by almost all pages that compose the - * File Browser frameset. - */ - -var FCKXml = function() -{} - -FCKXml.prototype.GetHttpRequest = function() -{ - // Gecko / IE7 - try { return new XMLHttpRequest(); } - catch(e) {} - - // IE6 - try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } - catch(e) {} - - // IE5 - try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } - catch(e) {} - - return null ; -} - -FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) -{ - var oFCKXml = this ; - - var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; - - var oXmlHttp = this.GetHttpRequest() ; - - oXmlHttp.open( "GET", urlToCall, bAsync ) ; - - if ( bAsync ) - { - oXmlHttp.onreadystatechange = function() - { - if ( oXmlHttp.readyState == 4 ) - { - var oXml ; - try - { - // this is the same test for an FF2 bug as in fckxml_gecko.js - // but we've moved the responseXML assignment into the try{} - // so we don't even have to check the return status codes. - var test = oXmlHttp.responseXML.firstChild ; - oXml = oXmlHttp.responseXML ; - } - catch ( e ) - { - try - { - oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; - } - catch ( e ) {} - } - - if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' ) - { - alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' + - 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' + - 'Requested URL:\n' + urlToCall + '\n\n' + - 'Response text:\n' + oXmlHttp.responseText ) ; - return ; - } - - oFCKXml.DOMDocument = oXml ; - asyncFunctionPointer( oFCKXml ) ; - } - } - } - - oXmlHttp.send( null ) ; - - if ( ! bAsync ) - { - if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) - this.DOMDocument = oXmlHttp.responseXML ; - else - { - alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; - } - } -} - -FCKXml.prototype.SelectNodes = function( xpath ) -{ - if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE - return this.DOMDocument.selectNodes( xpath ) ; - else // Gecko - { - var aNodeArray = new Array(); - - var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, - this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; - if ( xPathResult ) - { - var oNode = xPathResult.iterateNext() ; - while( oNode ) - { - aNodeArray[aNodeArray.length] = oNode ; - oNode = xPathResult.iterateNext(); - } - } - return aNodeArray ; - } -} - -FCKXml.prototype.SelectSingleNode = function( xpath ) -{ - if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE - return this.DOMDocument.selectSingleNode( xpath ) ; - else // Gecko - { - var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, - this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); - - if ( xPathResult && xPathResult.singleNodeValue ) - return xPathResult.singleNodeValue ; - else - return null ; - } -} +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Defines the FCKXml object that is used for XML data calls + * and XML processing. + * + * This script is shared by almost all pages that compose the + * File Browser frameset. + */ + +var FCKXml = function() +{} + +FCKXml.prototype.GetHttpRequest = function() +{ + // Gecko / IE7 + try { return new XMLHttpRequest(); } + catch(e) {} + + // IE6 + try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } + catch(e) {} + + // IE5 + try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } + catch(e) {} + + return null ; +} + +FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) +{ + var oFCKXml = this ; + + var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; + + var oXmlHttp = this.GetHttpRequest() ; + + oXmlHttp.open( "GET", urlToCall, bAsync ) ; + + if ( bAsync ) + { + oXmlHttp.onreadystatechange = function() + { + if ( oXmlHttp.readyState == 4 ) + { + var oXml ; + try + { + // this is the same test for an FF2 bug as in fckxml_gecko.js + // but we've moved the responseXML assignment into the try{} + // so we don't even have to check the return status codes. + var test = oXmlHttp.responseXML.firstChild ; + oXml = oXmlHttp.responseXML ; + } + catch ( e ) + { + try + { + oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; + } + catch ( e ) {} + } + + if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' ) + { + alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' + + 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' + + 'Requested URL:\n' + urlToCall + '\n\n' + + 'Response text:\n' + oXmlHttp.responseText ) ; + return ; + } + + oFCKXml.DOMDocument = oXml ; + asyncFunctionPointer( oFCKXml ) ; + } + } + } + + oXmlHttp.send( null ) ; + + if ( ! bAsync ) + { + if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) + this.DOMDocument = oXmlHttp.responseXML ; + else + { + alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; + } + } +} + +FCKXml.prototype.SelectNodes = function( xpath ) +{ + if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE + return this.DOMDocument.selectNodes( xpath ) ; + else // Gecko + { + var aNodeArray = new Array(); + + var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, + this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; + if ( xPathResult ) + { + var oNode = xPathResult.iterateNext() ; + while( oNode ) + { + aNodeArray[aNodeArray.length] = oNode ; + oNode = xPathResult.iterateNext(); + } + } + return aNodeArray ; + } +} + +FCKXml.prototype.SelectSingleNode = function( xpath ) +{ + if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE + return this.DOMDocument.selectSingleNode( xpath ) ; + else // Gecko + { + var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, + this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); + + if ( xPathResult && xPathResult.singleNodeValue ) + return xPathResult.singleNodeValue ; + else + return null ; + } +} diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 1f772550ffc2ab7a61aa76e041f863fc4716013d..c829933bf42d3bdc608eca4170ff6255671a0873 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -725,11 +725,11 @@ function activateModule($value,$withdeps=1) $num = count($objMod->depends); for ($i = 0; $i < $num; $i++) { - foreach ($modulesdir as $dir) + foreach ($modulesdir as $dir) { - if (file_exists($dir.$objMod->depends[$i].".class.php")) - { - activateModule($objMod->depends[$i]); + if (file_exists($dir.$objMod->depends[$i].".class.php")) + { + activateModule($objMod->depends[$i]); } } } @@ -741,11 +741,11 @@ function activateModule($value,$withdeps=1) $num = count($objMod->conflictwith); for ($i = 0; $i < $num; $i++) { - foreach ($modulesdir as $dir) + foreach ($modulesdir as $dir) { - if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) - { - unActivateModule($objMod->conflictwith[$i],0); + if (file_exists($dir.$objMod->conflictwith[$i].".class.php")) + { + unActivateModule($objMod->conflictwith[$i],0); } } } @@ -1128,16 +1128,16 @@ function form_constantes($tableau) print '</table>'; } -/** - * Add document model used by doc generator - * +/** + * Add document model used by doc generator + * * @param string $name Model name - * @param string $type Model type - * @param string $label Model label - * @param string $description Model description - * @return int <0 if KO, >0 if OK - */ -function addDocumentModel($name, $type, $label='', $description='') + * @param string $type Model type + * @param string $label Model label + * @param string $description Model description + * @return int <0 if KO, >0 if OK + */ +function addDocumentModel($name, $type, $label='', $description='') { global $db, $conf; @@ -1150,51 +1150,51 @@ function addDocumentModel($name, $type, $label='', $description='') $sql.= ")"; dol_syslog("admin.lib::addDocumentModel sql=".$sql); - $resql=$db->query($sql); - if ($resql) - { + $resql=$db->query($sql); + if ($resql) + { $db->commit(); - return 1; - } - else - { + return 1; + } + else + { dol_print_error($db); - $db->rollback(); - return -1; - } + $db->rollback(); + return -1; + } } -/** - * Delete document model used by doc generator - * - * @param string $name Model name - * @param string $type Model type - * @return int <0 if KO, >0 if OK - */ -function delDocumentModel($name, $type) -{ +/** + * Delete document model used by doc generator + * + * @param string $name Model name + * @param string $type Model type + * @return int <0 if KO, >0 if OK + */ +function delDocumentModel($name, $type) +{ global $db, $conf; $db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE nom = '".$db->escape($name)."'"; $sql.= " AND type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; - - dol_syslog("admin.lib::delDocumentModel sql=".$sql); - $resql=$db->query($sql); - if ($resql) - { + $sql.= " AND entity = ".$conf->entity; + + dol_syslog("admin.lib::delDocumentModel sql=".$sql); + $resql=$db->query($sql); + if ($resql) + { $db->commit(); - return 1; - } - else - { + return 1; + } + else + { dol_print_error($db); - $db->rollback(); - return -1; - } + $db->rollback(); + return -1; + } } ?> diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 09fc90fe7c55636ffff5afb229a78d236c49355a..f8bf5d4530bd91d26df0fd87f506d37ce294180d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -595,99 +595,99 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') return $i; } -/** - * Show html area for list of addresses - * - * @param Conf $conf Object conf - * @param Translate $langs Object langs - * @param DoliDB $db Database handler - * @param Object $object Third party object - * @param string $backtopage Url to go once address is created - * @return void - */ -function show_addresses($conf,$langs,$db,$object,$backtopage='') -{ - global $user; +/** + * Show html area for list of addresses + * + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Database handler + * @param Object $object Third party object + * @param string $backtopage Url to go once address is created + * @return void + */ +function show_addresses($conf,$langs,$db,$object,$backtopage='') +{ + global $user; global $bc; - require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); - + require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php"); + $addressstatic = new Address($db); - $num = $addressstatic->fetch_lines($object->id); - - $buttoncreate=''; - if ($user->rights->societe->creer) - { - $buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n"; - } - - print "\n"; - print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,''); - - print "\n".'<table class="noborder" width="100%">'."\n"; - - print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>'; + $num = $addressstatic->fetch_lines($object->id); + + $buttoncreate=''; + if ($user->rights->societe->creer) + { + $buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&action=create&backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n"; + } + + print "\n"; + print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,''); + + print "\n".'<table class="noborder" width="100%">'."\n"; + + print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("CompanyName").'</td>'; print '<td>'.$langs->trans("Town").'</td>'; print '<td>'.$langs->trans("Country").'</td>'; - print '<td>'.$langs->trans("Tel").'</td>'; - print '<td>'.$langs->trans("Fax").'</td>'; - print "<td> </td>"; - print "</tr>"; - - if ($num > 0) - { - $var=true; - - foreach ($addressstatic->lines as $address) - { - $var = !$var; - - print "<tr ".$bc[$var].">"; - + print '<td>'.$langs->trans("Tel").'</td>'; + print '<td>'.$langs->trans("Fax").'</td>'; + print "<td> </td>"; + print "</tr>"; + + if ($num > 0) + { + $var=true; + + foreach ($addressstatic->lines as $address) + { + $var = !$var; + + print "<tr ".$bc[$var].">"; + print '<td>'; $addressstatic->id = $address->id; - $addressstatic->label = $address->label; - print $addressstatic->getNomUrl(1); - print '</td>'; - + $addressstatic->label = $address->label; + print $addressstatic->getNomUrl(1); + print '</td>'; + print '<td>'.$address->name.'</td>'; print '<td>'.$address->town.'</td>'; $img=picto_from_langcode($address->country_code); - print '<td>'.($img?$img.' ':'').$address->country.'</td>'; - - // Lien click to dial - print '<td>'; - print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL'); - print '</td>'; - print '<td>'; - print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX'); - print '</td>'; - - if ($user->rights->societe->creer) - { - print '<td align="right">'; - print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&id='.$address->id.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">'; - print img_edit(); - print '</a></td>'; - } - - print "</tr>\n"; - } - } - else - { - //print "<tr ".$bc[$var].">"; - //print '<td>'.$langs->trans("NoAddressYetDefined").'</td>'; - //print "</tr>\n"; - } - print "\n</table>\n"; - - print "<br>\n"; - - return $num; + print '<td>'.($img?$img.' ':'').$address->country.'</td>'; + + // Lien click to dial + print '<td>'; + print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL'); + print '</td>'; + print '<td>'; + print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX'); + print '</td>'; + + if ($user->rights->societe->creer) + { + print '<td align="right">'; + print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&id='.$address->id.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">'; + print img_edit(); + print '</a></td>'; + } + + print "</tr>\n"; + } + } + else + { + //print "<tr ".$bc[$var].">"; + //print '<td>'.$langs->trans("NoAddressYetDefined").'</td>'; + //print "</tr>\n"; + } + print "\n</table>\n"; + + print "<br>\n"; + + return $num; } /** diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php index 586abb9e719990b6e957107dc9175010e130f840..90a15cf958eede19856941681da136e64c88b6d3 100644 --- a/htdocs/core/lib/contract.lib.php +++ b/htdocs/core/lib/contract.lib.php @@ -39,11 +39,11 @@ function contract_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans("ContactsAddresses"); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans("ContactsAddresses"); + $head[$h][2] = 'contact'; $h++; } @@ -53,11 +53,11 @@ function contract_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'contract'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Note"); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Note"); + $head[$h][2] = 'note'; $h++; } diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index e31b708f09bef0ef6b4cf43f8e4fa3bdb1425fb3..08732c271af9bdf1949b992de6e9fa6cc5184df0 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -43,11 +43,11 @@ function fichinter_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('InterventionContact'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('InterventionContact'); + $head[$h][2] = 'contact'; $h++; } @@ -65,11 +65,11 @@ function fichinter_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; $h++; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 9e5a404ec10f305406f43fb76a68cd7ed285cc9e..06234ddb42cfec1596bc7c45ca7fe7d96c0ad789 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -507,9 +507,9 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1) */ function dol_unescapefile($filename) { - // Remove path information and dots around the filename, to prevent uploading - // into different directories or replacing hidden system files. - // Also remove control characters and spaces (\x00..\x20) around the filename: + // Remove path information and dots around the filename, to prevent uploading + // into different directories or replacing hidden system files. + // Also remove control characters and spaces (\x00..\x20) around the filename: return trim(basename($filename), ".\x00..\x20"); } @@ -628,15 +628,15 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable { if (is_object($object)) { - $object->src_file=$dest_file; - - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $errors=$interface->errors; - } + $object->src_file=$dest_file; + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('FILE_UPLOAD',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $errors=$interface->errors; + } // Fin appel triggers } else diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 1cd38ce0c9b460fae1a2e5f4bae683dc2bc9e7bf..96adf043259cfd093cd54b80fa9a21f95aaad598 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -41,11 +41,11 @@ function facturefourn_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; $h++; } @@ -55,11 +55,11 @@ function facturefourn_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; $h++; } @@ -107,11 +107,11 @@ function ordersupplier_prepare_head($object) $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; $h++; } @@ -121,11 +121,11 @@ function ordersupplier_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; - $head[$h][1] = $langs->trans("Notes"); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; + $head[$h][1] = $langs->trans("Notes"); + $head[$h][2] = 'note'; $h++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index db2cbd3e80d49a76b943cfda5e2d7d7636b44d7c..455758b6148f5161043493c1168b2ffac9269974 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4007,36 +4007,36 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888') if (! is_array($arraycolor)) return $colorifnotfound; return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]); } - -/** - * Convert a currency code into its symbol - * - * @param string $currency_code Currency code - * @return string Currency symbol encoded into UTF8 - */ -function getCurrencySymbol($currency_code) -{ - global $db, $form; - - $currency_sign = ''; - - if (! is_object($form)) $form = new Form($db); - - $form->load_cache_currencies(); - - if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) - { - foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) - { + +/** + * Convert a currency code into its symbol + * + * @param string $currency_code Currency code + * @return string Currency symbol encoded into UTF8 + */ +function getCurrencySymbol($currency_code) +{ + global $db, $form; + + $currency_sign = ''; + + if (! is_object($form)) $form = new Form($db); + + $form->load_cache_currencies(); + + if (function_exists("mb_convert_encoding") && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) + { + foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) + { $currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES'); - } - } - else - { - $currency_sign = $currency_code; - } - - return $currency_sign; + } + } + else + { + $currency_sign = $currency_code; + } + + return $currency_sign; } if (! function_exists('getmypid')) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index a0305ef3ed84a98716fa5bdc45bfdbb0404af80e..212af105564ab7cf04d915dfa8ee04ea3c5b1f3f 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -185,7 +185,7 @@ function dol_print_object_info($object) $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); $deltadateforuser=round($deltadateforclient-$deltadateforserver); - //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; + //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; // Import key if (isset($object->import_key)) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index b6dd10249e34bb7a870fc98a50d65760d2deebaa..50753fc2818bfd0edf47c012ff868c795e3d80bc 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -40,11 +40,11 @@ function facture_prepare_head($object) $head[$h][2] = 'compta'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; $h++; } @@ -71,11 +71,11 @@ function facture_prepare_head($object) // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice'); - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; $h++; } diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index de7b61b133a9a3d3b396bb55a2a4e21459d80b84..b6df49225344c4145b4c44cc20c1bef1d797f25c 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -25,60 +25,60 @@ if (! function_exists('json_encode')) { - /** - * Implement json_encode for PHP that does not support it - * - * @param mixed $elements PHP Object to json encode - * @return string Json encoded string - */ - function json_encode($elements) + /** + * Implement json_encode for PHP that does not support it + * + * @param mixed $elements PHP Object to json encode + * @return string Json encoded string + */ + function json_encode($elements) { return dol_json_encode($elements); } } -/** - * Implement json_encode for PHP that does not support it - * - * @param mixed $elements PHP Object to json encode - * @return string Json encoded string - */ -function dol_json_encode($elements) -{ - $num = count($elements); - - // determine type - if (is_numeric(key($elements))) - { - // indexed (list) - $output = '['; - for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i) - { - if (is_array($elements[$i])) $output.= json_encode($elements[$i]); - else $output .= _val($elements[$i]); - if($i !== $last) $output.= ','; - } - $output.= ']'; - } - else - { - // associative (object) - $output = '{'; - $last = $num - 1; - $i = 0; - foreach($elements as $key => $value) - { - $output .= '"'.$key.'":'; - if (is_array($value)) $output.= json_encode($value); - else $output .= _val($value); - if ($i !== $last) $output.= ','; - ++$i; - } - $output.= '}'; - } - - // return - return $output; +/** + * Implement json_encode for PHP that does not support it + * + * @param mixed $elements PHP Object to json encode + * @return string Json encoded string + */ +function dol_json_encode($elements) +{ + $num = count($elements); + + // determine type + if (is_numeric(key($elements))) + { + // indexed (list) + $output = '['; + for ($i = 0, $last = ($num - 1); isset($elements[$i]); ++$i) + { + if (is_array($elements[$i])) $output.= json_encode($elements[$i]); + else $output .= _val($elements[$i]); + if($i !== $last) $output.= ','; + } + $output.= ']'; + } + else + { + // associative (object) + $output = '{'; + $last = $num - 1; + $i = 0; + foreach($elements as $key => $value) + { + $output .= '"'.$key.'":'; + if (is_array($value)) $output.= json_encode($value); + else $output .= _val($value); + if ($i !== $last) $output.= ','; + ++$i; + } + $output.= '}'; + } + + // return + return $output; } /** @@ -189,70 +189,70 @@ function _val($val) if (! function_exists('json_decode')) { - /** - * Implement json_decode for PHP that does not support it - * - * @param string $json Json encoded to PHP Object or Array - * @param bool $assoc False return an object, true return an array - * @return mixed Object or Array - */ - function json_decode($json, $assoc=false) + /** + * Implement json_decode for PHP that does not support it + * + * @param string $json Json encoded to PHP Object or Array + * @param bool $assoc False return an object, true return an array + * @return mixed Object or Array + */ + function json_decode($json, $assoc=false) { return dol_json_decode($json, $assoc); } } -/** - * Implement json_decode for PHP that does not support it - * - * @param string $json Json encoded to PHP Object or Array - * @param bool $assoc False return an object, true return an array. Try to always use it with true ! - * @return mixed Object or Array - */ -function dol_json_decode($json, $assoc=false) -{ - $comment = false; - +/** + * Implement json_decode for PHP that does not support it + * + * @param string $json Json encoded to PHP Object or Array + * @param bool $assoc False return an object, true return an array. Try to always use it with true ! + * @return mixed Object or Array + */ +function dol_json_decode($json, $assoc=false) +{ + $comment = false; + $out=''; - $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length - for ($i=0; $i<$strLength; $i++) - { - if (! $comment) - { - if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; - else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; - else if ($json[$i] == ':') $out.= ' => '; - else $out.=$json[$i]; - } - else $out.= $json[$i]; - if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; - } - - $out=_unval($out); - - // Return an array + $strLength = strlen($json); // Must stay strlen and not dol_strlen because we want technical length, not visible length + for ($i=0; $i<$strLength; $i++) + { + if (! $comment) + { + if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; + else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; + else if ($json[$i] == ':') $out.= ' => '; + else $out.=$json[$i]; + } + else $out.= $json[$i]; + if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment; + } + + $out=_unval($out); + + // Return an array if ($out != '') eval('$array = '.$out.';'); - else $array=array(); - - // Return an object - if (! $assoc) - { - if (! empty($array)) - { - $object = false; - - foreach ($array as $key => $value) - { - $object->{$key} = $value; - } - - return $object; - } - - return false; - } - - return $array; + else $array=array(); + + // Return an object + if (! $assoc) + { + if (! empty($array)) + { + $object = false; + + foreach ($array as $key => $value) + { + $object->{$key} = $value; + } + + return $object; + } + + return false; + } + + return $array; } /** diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 8cc3d939a00ba4b638bd4a3d4f7cbb32b78bd6b7..0ba1d9451dc339514bf1176e6c442f4c98c079cf 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -68,11 +68,11 @@ function commande_prepare_head($object) $h++; } - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; $h++; } @@ -91,11 +91,11 @@ function commande_prepare_head($object) $head[$h][2] = 'documents'; $h++; - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - $head[$h][2] = 'note'; + $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + $head[$h][2] = 'note'; $h++; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cf0b8243ba3f300900e795025012bb0f0b801761..e1f4b5a9fd117d51f5d4624ede8cc94b784fc508 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -714,7 +714,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass } } -/** +/** * Show linked objects for PDF generation * * @param PDF &$pdf Object PDF @@ -728,8 +728,8 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass * @param string $default_font_size Font size * @param HookManager $hookmanager Hook manager object * @return void - */ -function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false) + */ +function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$align,$default_font_size,$hookmanager=false) { $linkedobjects = pdf_getLinkedObjects($object,$outputlangs,$hookmanager); if (! empty($linkedobjects)) @@ -743,14 +743,14 @@ function pdf_writeLinkedObjects(&$pdf,$object,$outputlangs,$posx,$posy,$w,$h,$al if (! empty($linkedobject["date_title"]) && ! empty($linkedobject["date_value"])) { - $posy+=3; - $pdf->SetXY($posx,$posy); + $posy+=3; + $pdf->SetXY($posx,$posy); $pdf->MultiCell($w, $h, $linkedobject["date_title"].' : '.$linkedobject["date_value"], '', $align); } } } - - return $pdf->getY(); + + return $pdf->getY(); } /** @@ -1354,26 +1354,26 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false) */ function pdf_getCurrencySymbol(&$pdf, $currency_code) { - global $db, $form; - - $currency_sign = ''; - - if (! is_object($form)) $form = new Form($db); - - $form->load_cache_currencies(); - - if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) - { - foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) - { - $currency_sign.= $pdf->unichr($unicode); - } - } - else - { - $currency_sign = $currency_code; - } - + global $db, $form; + + $currency_sign = ''; + + if (! is_object($form)) $form = new Form($db); + + $form->load_cache_currencies(); + + if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode'])) + { + foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode) + { + $currency_sign.= $pdf->unichr($unicode); + } + } + else + { + $currency_sign = $currency_code; + } + return $currency_sign; } @@ -1417,25 +1417,25 @@ function pdf_getLinkedObjects($object,$outputlangs,$hookmanager=false) $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date,'day','',$outputlangs); } } - else if ($objecttype == 'contrat') - { - $outputlangs->load('contracts'); - $num=count($objects); - for ($i=0;$i<$num;$i++) + else if ($objecttype == 'contrat') + { + $outputlangs->load('contracts'); + $num=count($objects); + for ($i=0;$i<$num;$i++) { $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefContract"); $linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($objects[$i]->ref); $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); $linkedobjects[$objecttype]['date_value'] = dol_print_date($objects[$i]->date_contrat,'day','',$outputlangs); - } + } } } // For add external linked objects if (is_object($hookmanager)) { - $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); - $action=''; + $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); + $action=''; $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e11a654fa753885bba475283b768d733349347f0..fdbf774fd25b1dcdb0eb0e6e34ce819f7b1e2ae8 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -155,9 +155,9 @@ function product_admin_prepare_head($object=null) if ($conf->global->MAIN_FEATURES_LEVEL > 1) { - $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php'; - $head[$h][1] = $langs->trans("Tools"); - $head[$h][2] = 'tools'; + $head[$h][0] = DOL_URL_ROOT.'/product/admin/product_tools.php'; + $head[$h][1] = $langs->trans("Tools"); + $head[$h][2] = 'tools'; $h++; } diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index de7470c07f0980fdd32dc74ad5a28ab1108ef3a2..23439d25806a5d1fea452d3fb00d16ace865d88e 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -65,9 +65,9 @@ function propal_prepare_head($object) if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; - $head[$h][1] = $langs->trans('ContactsAddresses'); - $head[$h][2] = 'contact'; + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; + $head[$h][1] = $langs->trans('ContactsAddresses'); + $head[$h][2] = 'contact'; $h++; } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 54567b0bc666145326b86aea866b6b31b904c3c8..adc3783a458a20c6e890263792cfd4cfd283a278 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -379,9 +379,9 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature } else { - $sql = "SELECT dbt.".$dbt_select; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." = ".$objectid; + $sql = "SELECT dbt.".$dbt_select; + $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql.= " WHERE dbt.".$dbt_select." = ".$objectid; $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 38bef800d295a55cac80d4fd079005dd0bfc5a5d..3ad369af05f13853f34e60a90b9262daff5b695c 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -72,14 +72,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod $mode=trim($mode); $authfile='functions_'.$mode.'.php'; $fullauthfile=''; - - $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); - foreach($dirlogin as $reldir) - { - $dir=dol_buildpath($reldir,0); - $newdir=dol_osencode($dir); - - // Check if file found (do not use dol_is_file to avoid loading files.lib.php) + + $dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']); + foreach($dirlogin as $reldir) + { + $dir=dol_buildpath($reldir,0); + $newdir=dol_osencode($dir); + + // Check if file found (do not use dol_is_file to avoid loading files.lib.php) if (is_file($newdir.'/'.$authfile)) $fullauthfile=$newdir.'/'.$authfile; } @@ -130,12 +130,12 @@ function dol_loginfunction($langs,$conf,$mysoc) global $dolibarr_main_demo,$db; global $smartphone,$hookmanager; - // Instantiate hooks of thirdparty module only if not already define - if (! is_object($hookmanager)) - { - include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); - $hookmanager=new HookManager($db); - } + // Instantiate hooks of thirdparty module only if not already define + if (! is_object($hookmanager)) + { + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + $hookmanager=new HookManager($db); + } $hookmanager->initHooks(array('mainloginpage')); $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); @@ -205,8 +205,8 @@ function dol_loginfunction($langs,$conf,$mysoc) } // Execute hook getLoginPageOptions - // Should be an array with differents options in $hookmanager->resArray - $parameters=array('entity' => $_POST['entity']); + // Should be an array with differents options in $hookmanager->resArray + $parameters=array('entity' => $_POST['entity']); $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks // Login diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 4003db494674974859439efc26fd4c7b53674571..8db20829196518e731c271a17957d0f04d7f8d88 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -47,13 +47,13 @@ function shipping_prepare_head($object) if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) { - // delivery link + // delivery link $object->fetchObjectLinked($object->id,$object->element); if (! empty($object->linkedObjectsIds['delivery'][0])) { - $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0]; - $head[$h][1] = $langs->trans("DeliveryCard"); - $head[$h][2] = 'delivery'; + $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0]; + $head[$h][1] = $langs->trans("DeliveryCard"); + $head[$h][2] = 'delivery'; $h++; } } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 22d0bdbfd0a785d201b319747750ef9236b699f3..ddcbc7cf668e87a0c3770733cefb08049870a7c6 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -219,53 +219,53 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) foreach($dirthemes as $dir) { - $dirtheme=dol_buildpath($dir,0); + $dirtheme=dol_buildpath($dir,0); $urltheme=dol_buildpath($dir,1); - if (is_dir($dirtheme)) + if (is_dir($dirtheme)) { - $handle=opendir($dirtheme); - if (is_resource($handle)) - { - while (($subdir = readdir($handle))!==false) - { - if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' - && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir)) - { - // Disable not stable themes - //if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue; - - if ($i % $thumbsbyrow == 0) - { - print '<tr '.$bc[$var].'>'; - } - - print '<td align="center">'; - $file=$dirtheme."/".$subdir."/thumb.png"; - $url=$urltheme."/".$subdir."/thumb.png"; - if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg"; - print '<table><tr><td>'; - print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">'; - if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive"); - else $title=$langs->trans("ShowPreview"); - print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">'; - print '</a>'; - print '</td></tr><tr><td align="center">'; - if ($subdir == $selected_theme) - { - print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>'; - } - else - { - print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir; - } - print '</td></tr></table></td>'; - - $i++; - - if ($i % $thumbsbyrow == 0) print '</tr>'; - } - } + $handle=opendir($dirtheme); + if (is_resource($handle)) + { + while (($subdir = readdir($handle))!==false) + { + if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.' + && substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir)) + { + // Disable not stable themes + //if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue; + + if ($i % $thumbsbyrow == 0) + { + print '<tr '.$bc[$var].'>'; + } + + print '<td align="center">'; + $file=$dirtheme."/".$subdir."/thumb.png"; + $url=$urltheme."/".$subdir."/thumb.png"; + if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg"; + print '<table><tr><td>'; + print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">'; + if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive"); + else $title=$langs->trans("ShowPreview"); + print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">'; + print '</a>'; + print '</td></tr><tr><td align="center">'; + if ($subdir == $selected_theme) + { + print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>'; + } + else + { + print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir; + } + print '</td></tr></table></td>'; + + $i++; + + if ($i % $thumbsbyrow == 0) print '</tr>'; + } + } } } } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3ff00325bffd3369c733253f8f912e0993432172..b92e687c747b24864a9b2593a7f4d94fbf7ebc06 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1370,7 +1370,7 @@ abstract class DolibarrModules { foreach($this->module_parts as $key => $value) { - // If entity is defined + // If entity is defined if (is_array($value) && isset($value['entity'])) $entity = $value['entity']; $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; diff --git a/htdocs/core/modules/commande/doc/pdf_edison.modules.php b/htdocs/core/modules/commande/doc/pdf_edison.modules.php index 4121ffe7fe5a5474c33da3e98db03f83de9b82c6..0ec5df0960dd28e1eb81b24198bfadb16ce9df40 100644 --- a/htdocs/core/modules/commande/doc/pdf_edison.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_edison.modules.php @@ -300,7 +300,7 @@ class pdf_edison extends ModelePDFCommandes // Actions on extra fields (by external module or standard code) if (! is_object($hookmanager)) { - include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); + include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); @@ -651,7 +651,7 @@ class pdf_edison extends ModelePDFCommandes $posy+=1; - + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'L', $default_font_size, $hookmanager); } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 322bc572c55b64d422d6210f2f16fddbd7ddf7ae..28289c90024cb267d20e154083f8bb7e009ff791 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -929,8 +929,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); - $posy+=2; - + $posy+=2; + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 5a1b6034d42bf5923055753a7b819eda3a884219..44ad66059a84b2441d5a4d88b588cea5d50a92c2 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -154,37 +154,37 @@ class MailingTargets // This can't be abstract as it is used for some method { if (! empty($cibles[$i]['email'])) // avoid empty email address { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " (fk_mailing,"; - $sql .= " fk_contact,"; - $sql .= " nom, prenom, email, other, source_url, source_id,"; - if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,"; - $sql.= " source_type)"; - $sql .= " VALUES (".$mailing_id.","; - $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; - $sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; - $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; - if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; - $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; - $result=$this->db->query($sql); - if ($result) - { - $j++; - } - else - { - if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - // Si erreur autre que doublon - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles"; + $sql .= " (fk_mailing,"; + $sql .= " fk_contact,"; + $sql .= " nom, prenom, email, other, source_url, source_id,"; + if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= " tag,"; + $sql.= " source_type)"; + $sql .= " VALUES (".$mailing_id.","; + $sql .= (empty($cibles[$i]['fk_contact']) ? '0' : "'".$cibles[$i]['fk_contact']."'") .","; + $sql .= "'".$this->db->escape($cibles[$i]['name'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['firstname'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['email'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['other'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['source_url'])."',"; + $sql .= "'".$this->db->escape($cibles[$i]['source_id'])."',"; + if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) $sql .= "'".$this->db->escape(md5($cibles[$i]['email'].';'.$cibles[$i]['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; + $sql .= "'".$this->db->escape($cibles[$i]['source_type'])."')"; + $result=$this->db->query($sql); + if ($result) + { + $j++; + } + else + { + if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + // Si erreur autre que doublon + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } } } } diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 3044dbfd7eb8fed507274ebb7f4ba22fe5e10bda..ff7a97d1360e51b9f5316796504d56ccc70bb60d 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -74,8 +74,8 @@ class modMailing extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'mailing'; - $r=0; - + $r=0; + $r++; $this->rights[$r][0] = 221; // id de la permission $this->rights[$r][1] = 'Consulter les mailings'; // libelle de la permission @@ -104,28 +104,28 @@ class modMailing extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'supprimer'; - $r++; - $this->rights[$r][0] = 237; - $this->rights[$r][1] = 'View recipients and info'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $r++; + $this->rights[$r][0] = 237; + $this->rights[$r][1] = 'View recipients and info'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'recipient'; - $r++; - $this->rights[$r][0] = 238; - $this->rights[$r][1] = 'Manually send mailings'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $r++; + $this->rights[$r][0] = 238; + $this->rights[$r][1] = 'Manually send mailings'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'send'; - $r++; - $this->rights[$r][0] = 239; - $this->rights[$r][1] = 'Delete mailings after validation and/or sent'; - $this->rights[$r][2] = 'd'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on + $r++; + $this->rights[$r][0] = 239; + $this->rights[$r][1] = 'Delete mailings after validation and/or sent'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'delete'; } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6736747258eb718f1675fb3aeecdfe5e653df412..d3e82df991062656f843e924da95f5c0350e1576 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -982,9 +982,9 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); } - $posy+=2; - - // Show list of linked objects + $posy+=2; + + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); if ($showaddress) diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index 269b64faf609c902a21614597ce59915a7ec7cdf..a627ccdc3fb8da86fc89c85fc0c489f0b5b1c069 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -417,13 +417,13 @@ function thirdparty_doc_create($db, &$object, $message, $modele, $outputlangs) { $outputlangs->charset_output=$sav_charset_output; - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($db); - $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($db); + $result=$interface->run_triggers('COMPANY_BUILDDOC',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers return 1; diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 5724411047cd6657725c77431bddaf1f23508319..9da5a265c6f4ab61dbf941a7cac87750b982aa08 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -42,7 +42,7 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $langs->load("products"); $langs->load("other"); -$id=GETPOST('id','int'); +$id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $modulepart=GETPOST('modulepart','alpha')?GETPOST('modulepart','alpha'):'produit|service'; $original_file = isset($_REQUEST["file"])?urldecode($_REQUEST["file"]):''; @@ -65,12 +65,12 @@ if (! $accessallowed) } $object = new Product($db); -if ($id > 0) -{ +if ($id > 0) +{ $result = $object->fetch($id); if ($result <= 0) dol_print_error($db,'Failed to load object'); - $dir=$conf->product->multidir_output[$object->entity]; // By default - if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity]; + $dir=$conf->product->multidir_output[$object->entity]; // By default + if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity]; if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity]; } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 35f173fc57254d6503d17cebe089ea4d51d64f5e..53b19977b7d1a0b4f61e066dc553123ad7c698f3 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -16,17 +16,17 @@ * */ -$module = $object->element; -$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page - -// Special cases -if ($module == 'propal') { $permission=$user->rights->propale->creer; } -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } -elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } +$module = $object->element; +$permission=(isset($permission)?$permission:$user->rights->$module->creer); // If already defined by caller page + +// Special cases +if ($module == 'propal') { $permission=$user->rights->propale->creer; } +elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } +elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } $companystatic=new Societe($db); -$contactstatic=new Contact($db); +$contactstatic=new Contact($db); $userstatic=new User($db); ?> @@ -73,8 +73,8 @@ $userstatic=new User($db); <?php if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) { ?> <td> <?php - $events=array(); - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + $events=array(); + $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print $form->select_company($object->socid,'socid','',1,0,0,$events); ?> </td> @@ -113,12 +113,12 @@ $userstatic=new User($db); <?php $var=true; ?> <?php - foreach(array('internal','external') as $source) { - $tab = $object->liste_contact(-1,$source); - $num=count($tab); - - $i = 0; - while ($i < $num) { + foreach(array('internal','external') as $source) { + $tab = $object->liste_contact(-1,$source); + $num=count($tab); + + $i = 0; + while ($i < $num) { $var = !$var; ?> @@ -129,36 +129,36 @@ $userstatic=new User($db); </td> <td align="left"> <?php - if ($tab[$i]['socid'] > 0) - { - $companystatic->fetch($tab[$i]['socid']); - echo $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - echo $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - echo ' '; + if ($tab[$i]['socid'] > 0) + { + $companystatic->fetch($tab[$i]['socid']); + echo $companystatic->getNomUrl(1); + } + if ($tab[$i]['socid'] < 0) + { + echo $conf->global->MAIN_INFO_SOCIETE_NOM; + } + if (! $tab[$i]['socid']) + { + echo ' '; } ?> </td> <td> <?php - if ($tab[$i]['source']=='internal') - { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - echo $userstatic->getNomUrl(1); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; - echo $contactstatic->getNomUrl(1); + if ($tab[$i]['source']=='internal') + { + $userstatic->id=$tab[$i]['id']; + $userstatic->lastname=$tab[$i]['lastname']; + $userstatic->firstname=$tab[$i]['firstname']; + echo $userstatic->getNomUrl(1); + } + if ($tab[$i]['source']=='external') + { + $contactstatic->id=$tab[$i]['id']; + $contactstatic->lastname=$tab[$i]['lastname']; + $contactstatic->firstname=$tab[$i]['firstname']; + echo $contactstatic->getNomUrl(1); } ?> </td> diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 27c0944f8db242696b683bfa41e03f75e03b195b..277194635f5ef96fbbda8ea19c35e78c4aa0725d 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -35,7 +35,7 @@ print '<!-- Includes for JQuery (Ajax library) -->'."\n"; if (constant('JS_JQUERY_UI')) print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css" />'."\n"; // JQuery else print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" />'."\n"; // JQuery // JQuery. Must be before other includes -$ext='.js'; +$ext='.js'; if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x01)) $ext='.jgz'; print '<!-- Includes JS for JQuery -->'."\n"; if (constant('JS_JQUERY')) print '<script type="text/javascript" src="'.JS_JQUERY.'jquery.min.js"></script>'."\n"; diff --git a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php index dc577289df6b1f758b10f680f6b9d83219dd8ec8..ab78856e65fb450bbfbdddcfcac04c89da2bacfc 100755 --- a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php +++ b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php @@ -111,37 +111,37 @@ class InterfacePaypalWorkflow } else { - require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); - - $soc = new Societe($this->db); - - // Parse element/subelement (ex: project_task) - $element = $path = $filename = $object->source; - if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) - { - $element = $path = $regs[1]; - $filename = $regs[2]; - } - // For compatibility - if ($element == 'order') { - $path = $filename = 'commande'; - } - if ($element == 'invoice') { - $path = 'compta/facture'; $filename = 'facture'; - } - - dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); - - $classname = ucfirst($filename); - $obj = new $classname($this->db); - - $ret = $obj->fetch('',$object->ref); - if ($ret < 0) return -1; - - // Add payer id - $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); - - // Add transaction id + require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); + + $soc = new Societe($this->db); + + // Parse element/subelement (ex: project_task) + $element = $path = $filename = $object->source; + if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) + { + $element = $path = $regs[1]; + $filename = $regs[2]; + } + // For compatibility + if ($element == 'order') { + $path = $filename = 'commande'; + } + if ($element == 'invoice') { + $path = 'compta/facture'; $filename = 'facture'; + } + + dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); + + $classname = ucfirst($filename); + $obj = new $classname($this->db); + + $ret = $obj->fetch('',$object->ref); + if ($ret < 0) return -1; + + // Add payer id + $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); + + // Add transaction id $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d3fd5832a7830e620a123a309c15be89be6fe614..8abd1f270c8af39404bd8c1f6d6b40d1e69874c4 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -73,11 +73,11 @@ class Expedition extends CommonObject var $date_creation; var $date_valid; - // For Invoicing - var $total_ht; // Total net of tax - var $total_ttc; // Total with tax - var $total_tva; // Total VAT - var $total_localtax1; // Total Local tax 1 + // For Invoicing + var $total_ht; // Total net of tax + var $total_ttc; // Total with tax + var $total_tva; // Total VAT + var $total_localtax1; // Total Local tax 1 var $total_localtax2; // Total Local tax 2 @@ -871,10 +871,10 @@ class Expedition extends CommonObject $num = $this->db->num_rows($resql); $i = 0; - $this->total_ht = 0; - $this->total_tva = 0; - $this->total_ttc = 0; - $this->total_localtax1 = 0; + $this->total_ht = 0; + $this->total_tva = 0; + $this->total_ttc = 0; + $this->total_localtax1 = 0; $this->total_localtax2 = 0; while ($i < $num) @@ -915,11 +915,11 @@ class Expedition extends CommonObject $line->subprice = $obj->subprice; $line->remise_percent = $obj->remise_percent; - $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits); - $this->total_ht+= $tabprice[0]; - $this->total_tva+= $tabprice[1]; - $this->total_ttc+= $tabprice[2]; - $this->total_localtax1+= $tabprice[9]; + $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits); + $this->total_ht+= $tabprice[0]; + $this->total_tva+= $tabprice[1]; + $this->total_ttc+= $tabprice[2]; + $this->total_localtax1+= $tabprice[9]; $this->total_localtax2+= $tabprice[10]; $this->lines[$i] = $line; @@ -1212,28 +1212,28 @@ class Expedition extends CommonObject } } - /** - * Classify the shipping as invoiced - * - * @return int <0 if ko, >0 if ok - */ - function set_billed() - { - global $conf; - - $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; - $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; - if ($this->db->query($sql) ) + /** + * Classify the shipping as invoiced + * + * @return int <0 if ko, >0 if ok + */ + function set_billed() + { + global $conf; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2'; + $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;'; + if ($this->db->query($sql) ) { - //TODO: Option to set order billed if 100% of order is shipped - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } + //TODO: Option to set order billed if 100% of order is shipped + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } } @@ -1257,11 +1257,11 @@ class ExpeditionLigne var $ref; // Invoicing - var $remise_percent; - var $total_ht; // Total net of tax - var $total_ttc; // Total with tax - var $total_tva; // Total VAT - var $total_localtax1; // Total Local tax 1 + var $remise_percent; + var $total_ht; // Total net of tax + var $total_ttc; // Total with tax + var $total_tva; // Total VAT + var $total_localtax1; // Total Local tax 1 var $total_localtax2; // Total Local tax 2 diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 2637115a69797ed32bc7bbfef202773ecd96cbbe..86b7a2b86c1461b6faabd5384d9490b89a4314bf 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -119,11 +119,11 @@ else if ($action == 'deleteline' && $user->rights->expedition->creer) } } -else if ($action == 'setaddress' && $user->rights->expedition->creer) -{ - $object->fetch($id); - $result=$object->setDeliveryAddress($_POST['fk_address']); - if ($result < 0) dol_print_error($db,$object->error); +else if ($action == 'setaddress' && $user->rights->expedition->creer) +{ + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); } @@ -210,27 +210,27 @@ if ($id > 0 || ! empty($ref)) print '</td>'; print '</tr>'; - // Delivery address - if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) - { - print '<tr><td>'; - print '<table class="nobordernopadding" width="100%"><tr><td>'; - print $langs->trans('DeliveryAddress'); - print '</td>'; - - if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>'; - print '</tr></table>'; - print '</td><td colspan="3">'; - - if ($action == 'editdelivery_address') - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id); - } - else - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id); - } - print '</td></tr>'; + // Delivery address + if ($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) + { + print '<tr><td>'; + print '<table class="nobordernopadding" width="100%"><tr><td>'; + print $langs->trans('DeliveryAddress'); + print '</td>'; + + if ($action != 'editdelivery_address' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_address&socid='.$object->socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'</a></td>'; + print '</tr></table>'; + print '</td><td colspan="3">'; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','shipping',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','shipping',$object->id); + } + print '</td></tr>'; } print "</table>"; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 884644002978a08ee28f434a24eb85db9b81a8ac..fe66e772f3da73ab3ea3db7edbdfba9e477b3d72 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -60,7 +60,7 @@ $result=restrictedArea($user,$origin,$origin_id); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -509,10 +509,10 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile' } } -else if ($action == 'classifybilled') -{ - $object->fetch($id); - $object->set_billed(); +else if ($action == 'classifybilled') +{ + $object->fetch($id); + $object->set_billed(); } @@ -1340,9 +1340,9 @@ else $somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - /* - * Linked object block - */ + /* + * Linked object block + */ $somethingshown=$object->showLinkedObjectBlock(); if ($genallowed && ! $somethingshown) $somethingshown=1; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d697d0218f335198a62923f06dc575fdfca919d3..6862c855c5de7fe9f7301804091ce078a3d2a2f5 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -156,13 +156,13 @@ class Fichinter extends CommonObject $result=$this->db->query($sql); if ($result) { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); @@ -202,13 +202,13 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers $this->db->commit(); @@ -665,13 +665,13 @@ class Fichinter extends CommonObject } } - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers $this->db->commit(); diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 9ac5841bed11b95c204266d8c7f75e730a23825f..3cc37c7959b8f8795f1c7f41019b9342cfc2b99f 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -43,11 +43,11 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -118,20 +118,20 @@ if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } -// Delete -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $langs->load("other"); - $object->fetch_thirdparty(); - - $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } +// Delete +else if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id > 0) + { + $langs->load("other"); + $object->fetch_thirdparty(); + + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + dol_delete_file($file,0,0,0,$object); + $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } } @@ -178,15 +178,15 @@ if ($object->id) print '</div>'; - dol_htmloutput_mesg($mesg,$mesgs); - - /* + dol_htmloutput_mesg($mesg,$mesgs); + + /* * Confirmation suppression fichier - */ - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); - if ($ret == 'html') print '<br>'; + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '<br>'; } // Affiche formulaire upload diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index df4954aeee789ffbd896680852b52467840c7d2b..dfcc96aaa7dffb035dde719f1321f4de9b9675bb 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -50,7 +50,7 @@ $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); $mesg = GETPOST('msg','alpha'); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -200,21 +200,21 @@ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou } } -// Remove file in doc form -else if ($action == 'remove_file') -{ - if ($object->fetch($id)) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $object->fetch_thirdparty(); - - $langs->load("other"); - $upload_dir = $conf->ficheinter->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file,0,0,0,$object); - $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; - } +// Remove file in doc form +else if ($action == 'remove_file') +{ + if ($object->fetch($id)) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->ficheinter->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; + } } // Set into a project @@ -228,7 +228,7 @@ else if ($action == 'classin' && $user->rights->ficheinter->creer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) { $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch_thirdparty(); $object->delete($user); Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); @@ -382,30 +382,30 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST( */ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer) { - $objectline = new FichinterLigne($db); - if ($objectline->fetch(GETPOST('line_id','int')) <= 0) - { - dol_print_error($db); - exit; - } - $result=$objectline->deleteline(); - - if ($object->fetch($objectline->fk_fichinter) <= 0) - { - dol_print_error($db); - exit; - } - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } + $objectline = new FichinterLigne($db); + if ($objectline->fetch(GETPOST('line_id','int')) <= 0) + { + dol_print_error($db); + exit; + } + $result=$objectline->deleteline(); + + if ($object->fetch($objectline->fk_fichinter) <= 0) + { + dol_print_error($db); + exit; + } + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } fichinter_create($db, $object, $object->modelpdf, $outputlangs); } @@ -644,64 +644,64 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA $action='presend'; } -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->ficheinter->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->ficheinter->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); + $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha')); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { - $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int')); - $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha')); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; - } - else - { - $mesg = '<div class="error">'.$object->error.'</div>'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne','int')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) - { - $object->fetch($id); - $result = $object->delete_contact(GETPOST('lineid','int')); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; + } + else + { + $mesg = '<div class="error">'.$object->error.'</div>'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->ficheinter->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne','int')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->ficheinter->creer) + { + $object->fetch($id); + $result = $object->delete_contact(GETPOST('lineid','int')); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } } } @@ -941,15 +941,15 @@ else if ($id > 0 || ! empty($ref)) print "</table><br>"; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7de07317139f1fb5f0d93f7687b6d1cc3169db1e..9430d5acccdc8c4eee5952b158eab50f690adcb4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1298,44 +1298,44 @@ class CommandeFournisseur extends Commande $error++; } - if (! $error) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } // Fin appel triggers } - if (! $error) - { - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->fournisseur->commande->dir_output) - { - $dir = $conf->fournisseur->commande->dir_output . "/" . $ref ; - $file = $dir . "/" . $ref . ".pdf"; - if (file_exists($file)) - { - if (! dol_delete_file($file,0,0,0,$this)) // For triggers - { - $this->error='ErrorFailToDeleteFile'; - $error++; - } - } - if (file_exists($dir)) - { - $res=@dol_delete_dir_recursive($dir); - if (! $res) - { - $this->error='ErrorFailToDeleteDir'; - $error++; - } - } - } + if (! $error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->fournisseur->commande->dir_output) + { + $dir = $conf->fournisseur->commande->dir_output . "/" . $ref ; + $file = $dir . "/" . $ref . ".pdf"; + if (file_exists($file)) + { + if (! dol_delete_file($file,0,0,0,$this)) // For triggers + { + $this->error='ErrorFailToDeleteFile'; + $error++; + } + } + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $error++; + } + } + } } if (! $error) diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 06e01e26e04d0f95603a9f42d5837559b7309a25..b60a19e07a97b9fe05c245f45f11c07e61ee12f3 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -41,16 +41,16 @@ $langs->load('deliveries'); $langs->load('products'); $langs->load('stocks'); -$id = GETPOST('id','int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action','alpha'); +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -121,18 +121,18 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $langs->load("other"); - - $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - dol_delete_file($file,0,0,0,$object); - $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } +else if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id > 0) + { + $langs->load("other"); + + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + dol_delete_file($file,0,0,0,$object); + $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } } @@ -211,15 +211,15 @@ if ($object->id > 0) print "</div>\n"; - dol_htmloutput_mesg($mesg,$mesgs); - - /* - * Confirmation suppression fichier - */ - if ($action == 'delete') - { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); - if ($ret == 'html') print '<br>'; + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '<br>'; } // Affiche formulaire upload diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index fc947baf055e5e98357e918e416300be14c94765..f9dd67b16083a3be7c2b6623ff346e0be6ca23e2 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -55,7 +55,7 @@ $comclientid = GETPOST('comid','int'); $socid = GETPOST('socid','int'); $projectid = GETPOST('projectid','int'); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index ad133547fbcaf009566676a83e113a4109a2ada9..9c052738ea5893dcd439e16dfbedb9d6a7a917e1 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -46,7 +46,7 @@ $id = (GETPOST('facid','int') ? GETPOST('facid','int') : GETPOST('id','int')); $action = GETPOST("action"); $confirm = GETPOST("confirm"); -//PDF +//PDF $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -189,17 +189,17 @@ elseif ($action == 'setdate_lim_reglement' && $user->rights->fournisseur->factur $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); } -elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) +elseif ($action == 'setnote_public' && $user->rights->fournisseur->facture->creer) { - $object->fetch($id); - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} -elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer) + $object->fetch($id); + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} +elseif ($action == 'setnote' && $user->rights->fournisseur->facture->creer) { - $object->fetch($id); - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); + $object->fetch($id); + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); } // Delete payment @@ -437,7 +437,7 @@ elseif ($action == 'update_line') } - $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); + $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); @@ -834,64 +834,64 @@ elseif ($action == 'remove_file') } } -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) - { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) + if ($action == 'addcontact' && $user->rights->fournisseur->facture->creer) + { + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; - } - else - { - $mesg = '<div class="error">'.$object->error.'</div>'; - } - } - } - - // bascule du statut d'un contact - else if ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) - { - if ($object->fetch($id)) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) - { - $object->fetch($id); - $result = $object->delete_contact($_GET["lineid"]); - - if ($result >= 0) - { - Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - dol_print_error($db); - } + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>'; + } + else + { + $mesg = '<div class="error">'.$object->error.'</div>'; + } + } + } + + // bascule du statut d'un contact + else if ($action == 'swapstatut' && $user->rights->fournisseur->facture->creer) + { + if ($object->fetch($id)) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact' && $user->rights->fournisseur->facture->creer) + { + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } } } @@ -1504,23 +1504,23 @@ else print '</table><br>'; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); - require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); - $formcompany= new FormCompany($db); - - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { + require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); + $formcompany= new FormCompany($db); + + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { $colwidth=20; - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include(DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'); } diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 988b66930ec2a93003c7de7ca7ca7522d8fd2ed8..dd49c55faca3283a30694cfbf70b6edd6b2c1989 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -72,9 +72,9 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $search_ref = GETPOST('search_ref','alpha'); -$search_ref_supplier = GETPOST('search_ref_supplier','alpha'); -$search_societe = GETPOST('search_societe','alpha'); -$search_montant_ht = GETPOST('search_montant_ht','int'); +$search_ref_supplier = GETPOST('search_ref_supplier','alpha'); +$search_societe = GETPOST('search_societe','alpha'); +$search_montant_ht = GETPOST('search_montant_ht','int'); $search_montant_ttc = GETPOST('search_montant_ttc','int'); @@ -164,9 +164,9 @@ if ($user->rights->fournisseur->facture->lire) if ($socid) $param.="&socid=".$socid; if ($search_ref) $param.='&search_ref='.urlencode($search_ref); - if ($search_ref_supplier) $param.='&search_ref_supplier='.urlencode($search_ref_supplier); - if ($search_societe) $param.='&search_societe='.urlencode($search_societe); - if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); + if ($search_ref_supplier) $param.='&search_ref_supplier='.urlencode($search_ref_supplier); + if ($search_societe) $param.='&search_societe='.urlencode($search_societe); + if ($search_montant_ht) $param.='&search_montant_ht='.urlencode($search_montant_ht); if ($search_montant_ttc) $param.='&search_montant_ttc='.urlencode($search_montant_ttc); $param.=($option?"&option=".$option:""); diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index c0efba8e80ec5021e52d653532a600b3c463743d..4142ee966e5ec45f00adb94b748f1b64eea0fa1c 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -404,10 +404,10 @@ if ($object->fetch($id)) show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?id='.$object->id); } - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 352a1695c50a06e3484ef8ecef7f99555151572e..e4bb57b7aaf249c703e0a1b997ca249123e8ed51 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -237,7 +237,7 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); $defaultCollationConnection=getStaticMember(get_class($db),'forcecollate'); } else // If already created, we take current value diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 7d8bb61a0cbed87662394ec2a9f81cf3d7ae492e..d5490f6284f0bc414fe25d61f67bec56aff4cd39 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -81,11 +81,11 @@ if (! defined('DONOTLOADCONF') && file_exists($conffile)) { if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility - // Clean parameters - $dolibarr_main_data_root =isset($dolibarr_main_data_root)?trim($dolibarr_main_data_root):''; - $dolibarr_main_url_root =isset($dolibarr_main_url_root)?trim($dolibarr_main_url_root):''; - $dolibarr_main_url_root_alt =isset($dolibarr_main_url_root_alt)?trim($dolibarr_main_url_root_alt):''; - $dolibarr_main_document_root =isset($dolibarr_main_document_root)?trim($dolibarr_main_document_root):''; + // Clean parameters + $dolibarr_main_data_root =isset($dolibarr_main_data_root)?trim($dolibarr_main_data_root):''; + $dolibarr_main_url_root =isset($dolibarr_main_url_root)?trim($dolibarr_main_url_root):''; + $dolibarr_main_url_root_alt =isset($dolibarr_main_url_root_alt)?trim($dolibarr_main_url_root_alt):''; + $dolibarr_main_document_root =isset($dolibarr_main_document_root)?trim($dolibarr_main_document_root):''; $dolibarr_main_document_root_alt=isset($dolibarr_main_document_root_alt)?trim($dolibarr_main_document_root_alt):''; // Remove last / or \ on directories or url value diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index c51cf7ec28112e40a08075a0a694245e996fd218..b4d887fd7d8eea0d8d26b69771b61e8de8ea8aa6 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -27,20 +27,20 @@ * @param int $id Element id * @param string $table Table of Element */ -function checkElementExist($id, $table) -{ - global $db; - - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . $table; - $sql.= ' WHERE rowid = '.$id; - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); +function checkElementExist($id, $table) +{ + global $db; + + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . $table; + $sql.= ' WHERE rowid = '.$id; + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); if ($num > 0) return true; - else return false; + else return false; } - else return true; // for security + else return true; // for security } /** @@ -50,11 +50,11 @@ function checkElementExist($id, $table) * @param string $targettype Target element type * @return string */ -function checkLinkedElements($sourcetype, $targettype) -{ - global $db, $langs; - - $elements=array(); +function checkLinkedElements($sourcetype, $targettype) +{ + global $db, $langs; + + $elements=array(); $deleted=0; $sourcetable=$sourcetype; @@ -62,51 +62,51 @@ function checkLinkedElements($sourcetype, $targettype) if ($sourcetype == 'shipping') $sourcetable = 'expedition'; else if ($targettype == 'shipping') $targettable = 'expedition'; - if ($sourcetype == 'delivery') $sourcetable = 'livraison'; + if ($sourcetype == 'delivery') $sourcetable = 'livraison'; else if ($targettype == 'delivery') $targettable = 'livraison'; - if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur'; + if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur'; else if ($targettype == 'order_supplier') $targettable = 'commande_fournisseur'; - if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn'; + if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn'; else if ($targettype == 'invoice_supplier') $targettable = 'facture_fourn'; - $out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' '; - - $sql = 'SELECT * FROM '.MAIN_DB_PREFIX .'element_element'; - $sql.= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"'; - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $elements[$obj->rowid]=array($sourcetype => $obj->fk_source, $targettype => $obj->fk_target); - $i++; - } - } + $out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' '; + + $sql = 'SELECT * FROM '.MAIN_DB_PREFIX .'element_element'; + $sql.= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"'; + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $elements[$obj->rowid]=array($sourcetype => $obj->fk_source, $targettype => $obj->fk_target); + $i++; + } + } } - - if (! empty($elements)) - { - foreach($elements as $key => $element) + + if (! empty($elements)) + { + foreach($elements as $key => $element) { - if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable)) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element'; + if (! checkElementExist($element[$sourcetype], $sourcetable) || ! checkElementExist($element[$targettype], $targettable)) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX .'element_element'; $sql.= ' WHERE rowid = '.$key; - $resql=$db->query($sql); - $deleted++; - } - } + $resql=$db->query($sql); + $deleted++; + } + } } - if ($deleted) $out.= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>'; - else $out.= '('.$langs->trans('NothingToDelete').')<br>'; - - return $out; + if ($deleted) $out.= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>'; + else $out.= '('.$langs->trans('NothingToDelete').')<br>'; + + return $out; } ?> diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6931f421a2e21dfb40ab872d6bc0a6736dbf6b55..343645a486bbb1e62431441df23df83a07ad33de 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -893,8 +893,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; print '<link rel="stylesheet" type="text/css" title="default" href="'.$themepath.$themeparam.'">'."\n"; // CSS forced by modules (relative url starting with /) - $dircss=(array) $conf->modules_parts['css']; - foreach($dircss as $key => $cssfile) + $dircss=(array) $conf->modules_parts['css']; + foreach($dircss as $key => $cssfile) { // cssfile is a relative path print '<link rel="stylesheet" type="text/css" title="default" href="'.dol_buildpath($cssfile,1); @@ -991,7 +991,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-fp.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui.js"></script>'."\n"; - print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n"; + print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n"; '<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->'."\n"; } // jQuery DataTables @@ -1002,10 +1002,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/ColVis/js/ColVis.min'.$ext.'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/datatables/extras/TableTools/js/TableTools.min'.$ext.'"></script>'."\n"; } - // jQuery Multiselect - if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) - { - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n"; + // jQuery Multiselect + if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)) + { + print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/multiselect/js/ui.multiselect.js"></script>'."\n"; } // CKEditor if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')) @@ -1030,11 +1030,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/datepicker.js.php?lang='.$langs->defaultlang.'"></script>'."\n"; // JS forced by modules (relative url starting with /) - $dirjs=(array) $conf->modules_parts['js']; - foreach($dirjs as $key => $jsfile) - { - // jsfile is a relative path - print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$key. '-->'."\n"; + $dirjs=(array) $conf->modules_parts['js']; + foreach($dirjs as $key => $jsfile) + { + // jsfile is a relative path + print '<script type="text/javascript" src="'.dol_buildpath($jsfile,1).'"></script><!-- Added by module '.$key. '-->'."\n"; } // JS forced by page in top_htmlhead (relative url starting with /) if (is_array($arrayofjs)) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 2f3e8e3b91af1ce3e879f6845b00230905254591..dbaadbce9fb2340d3d62cdee6ec906c1b3b903a2 100755 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -763,28 +763,28 @@ function deformatNVP($nvpstr) return $nvpArray; } -/** +/** * Get API errors * - * @return array Array of errors - */ -function getApiError() -{ - $errors=array(); - - $resArray=$_SESSION['reshash']; - - if(isset($_SESSION['curl_error_no'])) - { - $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; - } - - foreach($resArray as $key => $value) - { - $errors[] = $key.'-'.$value; - } - - return $errors; + * @return array Array of errors + */ +function getApiError() +{ + $errors=array(); + + $resArray=$_SESSION['reshash']; + + if(isset($_SESSION['curl_error_no'])) + { + $errors[] = $_SESSION['curl_error_no'].'-'.$_SESSION['curl_error_msg']; + } + + foreach($resArray as $key => $value) + { + $errors[] = $key.'-'.$value; + } + + return $errors; } ?> \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 72c82c34348823155e52b9452a24c25e80715caa..340a13b66c77e5b1e189270e1b8db27219cbd184 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -511,32 +511,32 @@ class Product extends CommonObject if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) { - // We remove directory - if ($conf->product->dir_output) - { + // We remove directory + if ($conf->product->dir_output) + { $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); - $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); - if (file_exists($olddir)) - { - $res=@dol_move($olddir, $newdir); - if (! $res) - { - $this->error='ErrorFailToMoveDir'; - $error++; - } - } + $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); + if (file_exists($olddir)) + { + $res=@dol_move($olddir, $newdir); + if (! $res) + { + $this->error='ErrorFailToMoveDir'; + $error++; + } + } } } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -$error; + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -$error; } } else @@ -621,31 +621,31 @@ class Product extends CommonObject if (! $error) { - // We remove directory - $ref = dol_sanitizeFileName($this->ref); - if ($conf->product->dir_output) - { - $dir = $conf->product->dir_output . "/" . $ref; - if (file_exists($dir)) - { - $res=@dol_delete_dir_recursive($dir); - if (! $res) - { - $this->error='ErrorFailToDeleteDir'; - $error++; - } - } + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->product->dir_output) + { + $dir = $conf->product->dir_output . "/" . $ref; + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $error++; + } + } } } if (! $error) { - $this->db->commit(); + $this->db->commit(); return 1; } else { - $this->db->rollback(); + $this->db->rollback(); return -$error; } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f890d09cab73f8ad22030289f57d7a48a931de8b..d703039489b78200e5d51171e8c0ba66edf0f807 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -209,23 +209,23 @@ class Project extends CommonObject // End call triggers } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) - { - // We remove directory - if ($conf->projet->dir_output) - { - $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); - $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); - if (file_exists($olddir)) - { - $res=@dol_move($olddir, $newdir); - if (! $res) - { - $this->error='ErrorFailToMoveDir'; - $error++; - } - } - } + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) + { + // We remove directory + if ($conf->projet->dir_output) + { + $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref); + if (file_exists($olddir)) + { + $res=@dol_move($olddir, $newdir); + if (! $res) + { + $this->error='ErrorFailToMoveDir'; + $error++; + } + } + } } $result = 1; diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index c83952c073f869bb3f39d61cd7e3335f19d92b47..7386bf62719083c6bf9911275856056dc5aaa937 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -33,17 +33,17 @@ $langs->load('projects'); $langs->load('other'); $action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); -$id = GETPOST('id','int'); +$confirm = GETPOST('confirm','alpha'); +$id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); $mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0); //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -52,7 +52,7 @@ if ($user->societe_id > 0) $socid=$user->societe_id; $result=restrictedArea($user,'projet',$id,''); $object = new Project($db); -$object->fetch($id,$ref); +$object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index 797b4f4507c1f2852d064a205f17e44668b083e2..39368209f3167b05d660b36278a6f7c656cde922 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -49,11 +49,11 @@ $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); -$object = new Project($db); +$object = new Project($db); $object->fetch($id,$ref); -if ($object->id > 0) -{ - $object->fetch_thirdparty(); +if ($object->id > 0) +{ + $object->fetch_thirdparty(); } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index e9038d1c768066c6f228a6c13024c017e33c5336..b46115887757e1d3f45f0175cc40dcdaf02c1f9a 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -44,11 +44,11 @@ $ref= GETPOST('ref','alpha'); $withproject=GETPOST('withproject','int'); $project_ref = GETPOST('project_ref','alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php index 9648402e85b32d28f8f754435c8e5f0c583cf067..6aab3c023c7f3db4d555cc93816e41620a87caba 100644 --- a/htdocs/public/error-401.php +++ b/htdocs/public/error-401.php @@ -21,7 +21,7 @@ Sorry. You are not allowed to access this resource. <br> - <?php print isset($_SERVER["HTTP_REFERER"])?'You come from '.$_SERVER["HTTP_REFERER"].'.':''; ?> + <?php print isset($_SERVER["HTTP_REFERER"])?'You come from '.$_SERVER["HTTP_REFERER"].'.':''; ?> <hr> diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index c5435badeb16a991d10f97c33998c43ac100f5bb..64379be919cbbaa28fb3631a23d0e1b86aa54b46 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -27,11 +27,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); +// For MultiCompany module +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); +if (is_int($entity)) +{ + define("DOLENTITY", $entity); } require("../../main.inc.php"); diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index bf91f3616aa90982763169c99aa40fd156b6c91a..42a47f789f4b14f2b1a11442abfb8d4d4aa79198 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -27,11 +27,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); +// For MultiCompany module +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : 1); +if (is_int($entity)) +{ + define("DOLENTITY", $entity); } require("../../main.inc.php"); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 89d4b339bd926103cb7067a9b1d4e4c8b0f85bc5..cba0d9e4e7e1ac3b6ece21c0719a521c00ef9610 100755 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -27,11 +27,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); +// For MultiCompany module +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) +{ + define("DOLENTITY", $entity); } require("../../main.inc.php"); @@ -122,7 +122,7 @@ if (! empty($SECUREKEY)) } if (! empty($entity)) { - $urlok.='entity='.urlencode($entity).'&'; + $urlok.='entity='.urlencode($entity).'&'; $urlko.='entity='.urlencode($entity).'&'; } $urlok=preg_replace('/&$/','',$urlok); // Remove last & diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 243716ca70fbaaf11b84af9dd6a6e4a09d7c3e0a..695504c92527d42a12df7a864837896628244c23 100755 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -29,11 +29,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); +// For MultiCompany module +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) +{ + define("DOLENTITY", $entity); } require("../../main.inc.php"); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index d9d4cfac7298a6c65a2a026f4d028cbe7760def0..61e0bb0040ee6bd7b10621e4d68b0d791461e632 100755 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -29,11 +29,11 @@ define("NOLOGIN",1); // This means this output page does not require to be logged. define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -// For MultiCompany module -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); -if (is_int($entity)) -{ - define("DOLENTITY", $entity); +// For MultiCompany module +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_int($entity)) +{ + define("DOLENTITY", $entity); } require("../../main.inc.php"); diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index 819ee46d0c371dc5976ea8380747091b749c3762..f1a0815b4c74533e98dcbf89ead9cf146c23d917 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -206,28 +206,28 @@ class Address dol_syslog(get_class($this)."::Update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - dol_syslog(get_class($this)."::Update success"); - $this->db->commit(); - return 1; - } - else + if ($resql) { - if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - - $this->error=$langs->trans("ErrorDuplicateField",$this->name); - $result=-1; - } - else - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::Update error sql=".$sql, LOG_ERR); - $result=-2; - } - $this->db->rollback(); - return $result; + dol_syslog(get_class($this)."::Update success"); + $this->db->commit(); + return 1; + } + else + { + if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + + $this->error=$langs->trans("ErrorDuplicateField",$this->name); + $result=-1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::Update error sql=".$sql, LOG_ERR); + $result=-2; + } + $this->db->rollback(); + return $result; } } @@ -306,8 +306,8 @@ class Address // deprecated $line->cp = $line->zip; $line->ville = $line->town; - $line->pays_id = $line->country_id; - $line->pays_code = $line->country_code; + $line->pays_id = $line->country_id; + $line->pays_code = $line->country_code; $line->pays = $line->country; $line->tel = $line->phone; @@ -382,12 +382,12 @@ class Address $this->fax = $obj->fax; $this->note = $obj->note; - // deprecated - $line->cp = $line->zip; - $line->ville = $line->town; - $line->pays_id = $line->country_id; - $line->pays_code = $line->country_code; - $line->pays = $line->country; + // deprecated + $line->cp = $line->zip; + $line->ville = $line->town; + $line->pays_id = $line->country_id; + $line->pays_code = $line->country_code; + $line->pays = $line->country; $line->tel = $line->phone; $result = 1; @@ -436,26 +436,26 @@ class Address } } - /** - * Return name of address with link (and eventually picto) - * Use $this->id, $this->label, $this->socid - * - * @param int $withpicto Include picto with link - * @param string $option Where the link point to - * @return string String with URL - */ - function getNomUrl($withpicto=0,$option='') - { - global $langs; - - $result=''; - - $lien = '<a href="'.DOL_URL_ROOT.'/comm/address.php?id='.$this->id.'&socid='.$this->socid.'">'; - $lienfin='</a>'; - - if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); - $result.=$lien.$this->label.$lienfin; - return $result; + /** + * Return name of address with link (and eventually picto) + * Use $this->id, $this->label, $this->socid + * + * @param int $withpicto Include picto with link + * @param string $option Where the link point to + * @return string String with URL + */ + function getNomUrl($withpicto=0,$option='') + { + global $langs; + + $result=''; + + $lien = '<a href="'.DOL_URL_ROOT.'/comm/address.php?id='.$this->id.'&socid='.$this->socid.'">'; + $lienfin='</a>'; + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); + $result.=$lien.$this->label.$lienfin; + return $result; } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1cbf1cfc0d7b8e4023b4c9817e69c2e40ddcb79c..eee2d8d49c21e950f35632291cb8da52ad19a1c8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -446,10 +446,10 @@ class Societe extends CommonObject } if (! is_numeric($this->client) && ! is_numeric($this->fournisseur)) { - $langs->load("errors"); - $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); + $langs->load("errors"); + $this->error = $langs->trans("BadValueForParameterClientOrSupplier"); return -1; - } + } $this->db->begin(); @@ -481,8 +481,8 @@ class Societe extends CommonObject $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; $sql .= ",ape = '". $this->db->escape($this->idprof3) ."'"; $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; - $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; - $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; + $sql .= ",idprof5 = '". $this->db->escape($this->idprof5) ."'"; + $sql .= ",idprof6 = '". $this->db->escape($this->idprof6) ."'"; $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->tva_assuj."'":"null"); $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; @@ -731,8 +731,8 @@ class Societe extends CommonObject $this->idprof2 = $obj->idprof2; $this->idprof3 = $obj->idprof3; $this->idprof4 = $obj->idprof4; - $this->idprof5 = $obj->idprof5; - $this->idprof6 = $obj->idprof6; + $this->idprof5 = $obj->idprof5; + $this->idprof6 = $obj->idprof6; $this->capital = $obj->capital; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index a0a10011946652453f0d1d8399e41ffda7244c71..26aad2de1ddfdf8881c36685f33b90738305b1a4 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -36,14 +36,14 @@ $langs->load('other'); $action=GETPOST('action'); $confirm=GETPOST('confirm'); -$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); +$id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); $ref = GETPOST('ref', 'alpha'); -$mesg=''; -if (isset($_SESSION['DolMessage'])) -{ - $mesg=$_SESSION['DolMessage']; - unset($_SESSION['DolMessage']); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); } // Security check @@ -67,11 +67,11 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; $object = new Societe($db); -if ($id > 0 || ! empty($ref)) -{ +if ($id > 0 || ! empty($ref)) +{ $result = $object->fetch($id, $ref); - $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; + $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id); } @@ -149,88 +149,88 @@ llxHeader('',$langs->trans("ThirdParty").' - '.$langs->trans("Files"),$help_url) if ($object->id) { - /* + /* * Affichage onglets - */ - if ($conf->notification->enabled) $langs->load("mails"); - $head = societe_prepare_head($object); - - $form=new Form($db); - - dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company'); - - - // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $totalsize=0; - foreach($filearray as $key => $file) - { - $totalsize+=$file['size']; - } - - - print '<table class="border"width="100%">'; - - // Ref - print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td>'; - print '<td colspan="3">'; - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); - print '</td></tr>'; - - // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; - } - - if ($object->client) - { - print '<tr><td>'; - print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $object->code_client; - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; - print '</td></tr>'; - } - - if ($object->fournisseur) - { - print '<tr><td>'; - print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $object->code_fournisseur; - if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; - print '</td></tr>'; - } - - // Nbre fichiers - print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; - - //Total taille - print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; - - print '</table>'; - - print '</div>'; - - dol_htmloutput_mesg($mesg,$mesgs); - - /* - * Confirmation suppression fichier - */ - if ($action == 'delete') + */ + if ($conf->notification->enabled) $langs->load("mails"); + $head = societe_prepare_head($object); + + $form=new Form($db); + + dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print '<table class="border"width="100%">'; + + // Ref + print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td>'; + print '<td colspan="3">'; + print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); + print '</td></tr>'; + + // Prefix + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); - if ($ret == 'html') print '<br>'; - } - - $formfile=new FormFile($db); - - // Show upload form - $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,'',0,0,$user->rights->societe->creer,50,$object); - - // List of document - $param='&socid='.$object->id; - $formfile->list_of_documents($filearray,$object,'societe',$param); - + print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; + } + + if ($object->client) + { + print '<tr><td>'; + print $langs->trans('CustomerCode').'</td><td colspan="3">'; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; + print '</td></tr>'; + } + + if ($object->fournisseur) + { + print '<tr><td>'; + print $langs->trans('SupplierCode').'</td><td colspan="3">'; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; + print '</td></tr>'; + } + + // Nbre fichiers + print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; + + //Total taille + print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; + + print '</table>'; + + print '</div>'; + + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '<br>'; + } + + $formfile=new FormFile($db); + + // Show upload form + $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,'',0,0,$user->rights->societe->creer,50,$object); + + // List of document + $param='&socid='.$object->id; + $formfile->list_of_documents($filearray,$object,'societe',$param); + print "<br><br>"; } else diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b7f71df267f78d3624dae57e03474c4229af471b..012aff5818f265f3fdaec2022ed52fbc357ead25 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -451,19 +451,19 @@ if (empty($reshook)) } } - // Remove file in doc form - else if ($action == 'remove_file') - { - if ($object->fetch($socid)) - { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - - $langs->load("other"); - $upload_dir = $conf->societe->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file,0,0,0,$object); - $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; - } + // Remove file in doc form + else if ($action == 'remove_file') + { + if ($object->fetch($socid)) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $langs->load("other"); + $upload_dir = $conf->societe->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; + } } } @@ -1836,10 +1836,10 @@ else $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } // Projects list diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index d9663e867bc71fe33e13f08f1c21fd64ebe20ea9..d6a72b0e4e7021ea39fc7caa1f6e760ca10831c5 100755 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -124,46 +124,46 @@ $server->wsdl->addComplexType( ) ); -// Define other specific objects -$server->wsdl->addComplexType( - 'filterthirdparty', - 'complexType', - 'struct', - 'all', - '', - array( - //'limit' => array('name'=>'limit','type'=>'xsd:string'), - 'client' => array('name'=>'client','type'=>'xsd:string'), +// Define other specific objects +$server->wsdl->addComplexType( + 'filterthirdparty', + 'complexType', + 'struct', + 'all', + '', + array( + //'limit' => array('name'=>'limit','type'=>'xsd:string'), + 'client' => array('name'=>'client','type'=>'xsd:string'), 'supplier' => array('name'=>'supplier','type'=>'xsd:string') - ) -); - -$server->wsdl->addComplexType( - 'ThirdPartiesArray', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array( - array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:thirdparty[]') - ), - 'tns:thirdparty' + ) ); -$server->wsdl->addComplexType( - 'ThirdPartiesArray2', - 'complexType', - 'array', - 'sequence', - '', - array( - 'thirdparty' => array( - 'name' => 'thirdparty', - 'type' => 'tns:thirdparty', - 'minOccurs' => '0', - 'maxOccurs' => 'unbounded' - ) - ) + +$server->wsdl->addComplexType( + 'ThirdPartiesArray', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array( + array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:thirdparty[]') + ), + 'tns:thirdparty' +); +$server->wsdl->addComplexType( + 'ThirdPartiesArray2', + 'complexType', + 'array', + 'sequence', + '', + array( + 'thirdparty' => array( + 'name' => 'thirdparty', + 'type' => 'tns:thirdparty', + 'minOccurs' => '0', + 'maxOccurs' => 'unbounded' + ) + ) ); @@ -188,33 +188,33 @@ $server->register( 'WS to get a thirdparty from its id, ref or ref_ext' ); -// Register WSDL -$server->register( - 'createThirdParty', - // Entry values - array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'), - // Exit values - array('result'=>'tns:result','id'=>'xsd:string'), - $ns, - $ns.'#createThirdParty', - $styledoc, - $styleuse, - 'WS to create a thirdparty' +// Register WSDL +$server->register( + 'createThirdParty', + // Entry values + array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'), + // Exit values + array('result'=>'tns:result','id'=>'xsd:string'), + $ns, + $ns.'#createThirdParty', + $styledoc, + $styleuse, + 'WS to create a thirdparty' ); - -// Register WSDL -$server->register( - 'getListOfThirdParties', - // Entry values - array('authentication'=>'tns:authentication','filterthirdparty'=>'tns:filterthirdparty'), - // Exit values - array('result'=>'tns:result','thirdparties'=>'tns:ThirdPartiesArray2'), - $ns, - $ns.'#getListOfThirdParties', - $styledoc, - $styleuse, - 'WS to get list of thirdparties id and ref' + +// Register WSDL +$server->register( + 'getListOfThirdParties', + // Entry values + array('authentication'=>'tns:authentication','filterthirdparty'=>'tns:filterthirdparty'), + // Exit values + array('result'=>'tns:result','thirdparties'=>'tns:ThirdPartiesArray2'), + $ns, + $ns.'#getListOfThirdParties', + $styledoc, + $styleuse, + 'WS to get list of thirdparties id and ref' ); @@ -311,187 +311,187 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') } - -/** - * Create a thirdparty - * - * @param array $authentication Array of authentication information - * @param Societe $thirdparty Thirdparty - * @return array Array result - */ -function createThirdParty($authentication,$thirdparty) -{ - global $db,$conf,$langs; - - $now=dol_now(); - - dol_syslog("Function: createThirdParty login=".$authentication['login']); - - if ($authentication['entity']) $conf->entity=$authentication['entity']; - - // Init and check authentication - $objectresp=array(); - $errorcode='';$errorlabel=''; - $error=0; - $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); - // Check parameters - if (empty($thirdparty['ref'])) - { - $error++; $errorcode='KO'; $errorlabel="Name is mandatory."; - } - - - if (! $error) - { - include_once(DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'); - - $newobject=new Societe($db); - $newobject->ref=$thirdparty['ref']; + +/** + * Create a thirdparty + * + * @param array $authentication Array of authentication information + * @param Societe $thirdparty Thirdparty + * @return array Array result + */ +function createThirdParty($authentication,$thirdparty) +{ + global $db,$conf,$langs; + + $now=dol_now(); + + dol_syslog("Function: createThirdParty login=".$authentication['login']); + + if ($authentication['entity']) $conf->entity=$authentication['entity']; + + // Init and check authentication + $objectresp=array(); + $errorcode='';$errorlabel=''; + $error=0; + $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); + // Check parameters + if (empty($thirdparty['ref'])) + { + $error++; $errorcode='KO'; $errorlabel="Name is mandatory."; + } + + + if (! $error) + { + include_once(DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'); + + $newobject=new Societe($db); + $newobject->ref=$thirdparty['ref']; $newobject->name=$thirdparty['ref']; - $newobject->ref_ext=$thirdparty['ref_ext']; + $newobject->ref_ext=$thirdparty['ref_ext']; $newobject->status=$thirdparty['status']; - $newobject->client=$thirdparty['client']; + $newobject->client=$thirdparty['client']; $newobject->fournisseur=$thirdparty['supplier']; $newobject->code_client=$thirdparty['customer_code']; $newobject->code_fournisseur=$thirdparty['supplier_code']; $newobject->code_compta=$thirdparty['customer_code_accountancy']; $newobject->code_compta_fournisseur=$thirdparty['supplier_code_accountancy']; - $newobject->date_creation=$now; + $newobject->date_creation=$now; $newobject->note=$thirdparty['note']; - $newobject->address=$thirdparty['address']; - $newobject->zip=$thirdparty['zip']; - $newobject->town=$thirdparty['town']; - - $newobject->country_id=$thirdparty['country_id']; - if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3); - $newobject->province_id=$thirdparty['province_id']; - //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3); - + $newobject->address=$thirdparty['address']; + $newobject->zip=$thirdparty['zip']; + $newobject->town=$thirdparty['town']; + + $newobject->country_id=$thirdparty['country_id']; + if ($thirdparty['country_code']) $newobject->country_id=getCountry($thirdparty['country_code'],3); + $newobject->province_id=$thirdparty['province_id']; + //if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3); + $newobject->phone=$thirdparty['phone']; $newobject->fax=$thirdparty['fax']; $newobject->email=$thirdparty['email']; $newobject->url=$thirdparty['url']; - $newobject->idprof1=$thirdparty['profid1']; - $newobject->idprof2=$thirdparty['profid2']; - $newobject->idprof3=$thirdparty['profid3']; - $newobject->idprof4=$thirdparty['profid4']; - $newobject->idprof5=$thirdparty['profid5']; - $newobject->idprof6=$thirdparty['profid6']; + $newobject->idprof1=$thirdparty['profid1']; + $newobject->idprof2=$thirdparty['profid2']; + $newobject->idprof3=$thirdparty['profid3']; + $newobject->idprof4=$thirdparty['profid4']; + $newobject->idprof5=$thirdparty['profid5']; + $newobject->idprof6=$thirdparty['profid6']; $newobject->capital=$thirdparty['capital']; $newobject->barcode=$thirdparty['barcode']; - $newobject->tva_assuj=$thirdparty['vat_used']; - $newobject->tva_intra=$thirdparty['vat_number']; - - $newobject->canvas=$thirdparty['canvas']; - - $db->begin(); - - $result=$newobject->create($fuser); - if ($result <= 0) - { - $error++; - } - - if (! $error) - { - $db->commit(); - $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); - } - else - { - $db->rollback(); - $error++; - $errorcode='KO'; - $errorlabel=$newobject->error; - } - } - - if ($error) - { - $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); - } - - return $objectresp; -} - - - -/** - * getListOfThirdParties - * - * @param array $authentication Array of authentication information - * @param array $filterthirdparty Filter fields - * @return array Array result - */ -function getListOfThirdParties($authentication,$filterthirdparty) -{ - global $db,$conf,$langs; - - $now=dol_now(); - - dol_syslog("Function: getListOfThirdParties login=".$authentication['login']); - - if ($authentication['entity']) $conf->entity=$authentication['entity']; - - // Init and check authentication - $objectresp=array(); - $arraythirdparties=array(); - $errorcode='';$errorlabel=''; - $error=0; - $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); - // Check parameters - - if (! $error) - { - $sql ="SELECT rowid, nom as ref, ref_ext"; - $sql.=" FROM ".MAIN_DB_PREFIX."societe"; - $sql.=" WHERE entity=".$conf->entity; - foreach($filterthirdparty as $key => $val) - { - if ($key == 'client' && $val != '') $sql.=" AND client = ".$db->escape($val); + $newobject->tva_assuj=$thirdparty['vat_used']; + $newobject->tva_intra=$thirdparty['vat_number']; + + $newobject->canvas=$thirdparty['canvas']; + + $db->begin(); + + $result=$newobject->create($fuser); + if ($result <= 0) + { + $error++; + } + + if (! $error) + { + $db->commit(); + $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref); + } + else + { + $db->rollback(); + $error++; + $errorcode='KO'; + $errorlabel=$newobject->error; + } + } + + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } + + return $objectresp; +} + + + +/** + * getListOfThirdParties + * + * @param array $authentication Array of authentication information + * @param array $filterthirdparty Filter fields + * @return array Array result + */ +function getListOfThirdParties($authentication,$filterthirdparty) +{ + global $db,$conf,$langs; + + $now=dol_now(); + + dol_syslog("Function: getListOfThirdParties login=".$authentication['login']); + + if ($authentication['entity']) $conf->entity=$authentication['entity']; + + // Init and check authentication + $objectresp=array(); + $arraythirdparties=array(); + $errorcode='';$errorlabel=''; + $error=0; + $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); + // Check parameters + + if (! $error) + { + $sql ="SELECT rowid, nom as ref, ref_ext"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe"; + $sql.=" WHERE entity=".$conf->entity; + foreach($filterthirdparty as $key => $val) + { + if ($key == 'client' && $val != '') $sql.=" AND client = ".$db->escape($val); if ($key == 'supplier' && $val != '') $sql.=" AND fournisseur = ".$db->escape($val); - } - $resql=$db->query($sql); - if ($resql) - { - $num=$db->num_rows($resql); - - $i=0; - while ($i < $num) - { - $obj=$db->fetch_object($resql); - $arraythirdparties[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext); - $i++; - } - } - else - { - $error++; - $errorcode=$db->lasterrno(); - $errorlabel=$db->lasterror(); - } - } - - if ($error) - { - $objectresp = array( - 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), - 'thirdparties'=>$arraythirdparties - ); - } - else - { - $objectresp = array( - 'result'=>array('result_code' => 'OK', 'result_label' => ''), - 'thirdparties'=>$arraythirdparties - ); - } - - return $objectresp; + } + $resql=$db->query($sql); + if ($resql) + { + $num=$db->num_rows($resql); + + $i=0; + while ($i < $num) + { + $obj=$db->fetch_object($resql); + $arraythirdparties[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext); + $i++; + } + } + else + { + $error++; + $errorcode=$db->lasterrno(); + $errorlabel=$db->lasterror(); + } + } + + if ($error) + { + $objectresp = array( + 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), + 'thirdparties'=>$arraythirdparties + ); + } + else + { + $objectresp = array( + 'result'=>array('result_code' => 'OK', 'result_label' => ''), + 'thirdparties'=>$arraythirdparties + ); + } + + return $objectresp; } - + // Return the results. diff --git a/scripts/emailings/cron-mailing-send.php b/scripts/emailings/cron-mailing-send.php index 6962113f0051685abb8d76c897477b39874c26aa..903c268ab388889bbc20b5377c2975127d960b50 100644 --- a/scripts/emailings/cron-mailing-send.php +++ b/scripts/emailings/cron-mailing-send.php @@ -57,206 +57,206 @@ if ($resql) if ($num) { - for ($i=0;$i<$num;$i++) + for ($i=0;$i<$num;$i++) { - $obj = $db->fetch_object($resql); - - dol_syslog("mailing ".$obj->rowid); - - $id = $obj->rowid; - $subject = $obj->sujet; - $message = $obj->body; - $from = $obj->email_from; - $replyto = $obj->email_replyto; - $errorsto = $obj->email_errorsto; - // Le message est-il en html - $msgishtml=-1; // Unknown by default + $obj = $db->fetch_object($resql); + + dol_syslog("mailing ".$obj->rowid); + + $id = $obj->rowid; + $subject = $obj->sujet; + $message = $obj->body; + $from = $obj->email_from; + $replyto = $obj->email_replyto; + $errorsto = $obj->email_errorsto; + // Le message est-il en html + $msgishtml=-1; // Unknown by default if (preg_match('/[\s\t]*<html>/i',$message)) $msgishtml=1; - // Set statut 9 (in progress) to avoid duplication - $sql="UPDATE ".MAIN_DB_PREFIX."mailing"; - $sql.=" SET statut=9 WHERE rowid=".$id; - $resql3=$db->query($sql); - if (! $resql3) - { - dol_print_error($db); + // Set statut 9 (in progress) to avoid duplication + $sql="UPDATE ".MAIN_DB_PREFIX."mailing"; + $sql.=" SET statut=9 WHERE rowid=".$id; + $resql3=$db->query($sql); + if (! $resql3) + { + dol_print_error($db); } - $nbok=0; $nbko=0; - - // On choisit les mails non deja envoyes pour ce mailing (statut=0) - // ou envoyes en erreur (statut=-1) - $sql = "SELECT mc.rowid, mc.nom as lastname, mc.prenom as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; - $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; - - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - - if ($num) - { - dol_syslog("nb of targets = ".$num, LOG_DEBUG); - - $now=dol_now(); - - // Positionne date debut envoi - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$id; - - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - - // Look on each email and sent message - $i = 0; - while ($i < $num) - { - $res=1; - $now=dol_now(); - - $obj2 = $db->fetch_object($resql); - - // sendto en RFC2822 - $sendto = str_replace(',',' ',$obj2->firstname." ".$obj2->lastname) ." <".$obj2->email.">"; - - // Make subtsitutions on topic and body - $other=explode(';',$obj2->other); - $other1=$other[0]; - $other2=$other[1]; - $other3=$other[2]; - $other4=$other[3]; - $other5=$other[4]; - $substitutionarray=array( - '__ID__' => $obj2->source_id, - '__EMAIL__' => $obj2->email, - '__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'" width="1" height="1" style="width:1px;height:1px" border="0"/>', - '__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>', - '__MAILTOEMAIL__' => '<a href="mailto:'.$obj2->email.'">'.$obj2->email.'</a>', - '__LASTNAME__' => $obj2->lastname, - '__FIRSTNAME__' => $obj2->firstname, - '__OTHER1__' => $other1, - '__OTHER2__' => $other2, - '__OTHER3__' => $other3, - '__OTHER4__' => $other4, - '__OTHER5__' => $other5 - ); - - complete_substitutions_array($substitutionarray,$langs); - $newsubject=make_substitutions($subject,$substitutionarray); - $newmessage=make_substitutions($message,$substitutionarray); - - $substitutionisok=true; - - // Fabrication du mail - $mail = new CMailFile( - $newsubject, - $sendto, - $from, - $newmessage, - array(), - array(), - array(), - '', - '', - 0, - $msgishtml, - $errorsto - ); - - if ($mail->error) - { - $res=0; - } - if (! $substitutionisok) - { - $mail->error='Some substitution failed'; - $res=0; - } - - // Send Email - if ($res) - { - $res=$mail->sendfile(); - } - - if ($res) - { - // Mail successful - $nbok++; - - dol_syslog("ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj2->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - else - { - //if cheack read is use then update prospect contact status - if (strpos($message, '__CHECK_READ__') !== false && ! empty($obj2->source_id)) - { - //Update status communication of thirdparty prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj2->rowid.")"; - dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - - //Update status communication of contact prospect - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; - dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); - - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - } - } - else - { - // Mail failed - $nbko++; - - dol_syslog("error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj2->rowid; - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - - $i++; - } - } - - // Loop finished, set global statut of mail - $statut=2; - if (! $nbko) $statut=3; - - $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id; - dol_syslog("update global status sql=".$sql, LOG_DEBUG); - $resql2=$db->query($sql); - if (! $resql2) - { - dol_print_error($db); - } - } - else - { - dol_print_error($db); + $nbok=0; $nbko=0; + + // On choisit les mails non deja envoyes pour ce mailing (statut=0) + // ou envoyes en erreur (statut=-1) + $sql = "SELECT mc.rowid, mc.nom as lastname, mc.prenom as firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$id; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + if ($num) + { + dol_syslog("nb of targets = ".$num, LOG_DEBUG); + + $now=dol_now(); + + // Positionne date debut envoi + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$id; + + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + // Look on each email and sent message + $i = 0; + while ($i < $num) + { + $res=1; + $now=dol_now(); + + $obj2 = $db->fetch_object($resql); + + // sendto en RFC2822 + $sendto = str_replace(',',' ',$obj2->firstname." ".$obj2->lastname) ." <".$obj2->email.">"; + + // Make subtsitutions on topic and body + $other=explode(';',$obj2->other); + $other1=$other[0]; + $other2=$other[1]; + $other3=$other[2]; + $other4=$other[3]; + $other5=$other[4]; + $substitutionarray=array( + '__ID__' => $obj2->source_id, + '__EMAIL__' => $obj2->email, + '__CHECK_READ__' => '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj2->tag.'" width="1" height="1" style="width:1px;height:1px" border="0"/>', + '__UNSUSCRIBE__' => '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj2->tag.'&unsuscrib=1" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>', + '__MAILTOEMAIL__' => '<a href="mailto:'.$obj2->email.'">'.$obj2->email.'</a>', + '__LASTNAME__' => $obj2->lastname, + '__FIRSTNAME__' => $obj2->firstname, + '__OTHER1__' => $other1, + '__OTHER2__' => $other2, + '__OTHER3__' => $other3, + '__OTHER4__' => $other4, + '__OTHER5__' => $other5 + ); + + complete_substitutions_array($substitutionarray,$langs); + $newsubject=make_substitutions($subject,$substitutionarray); + $newmessage=make_substitutions($message,$substitutionarray); + + $substitutionisok=true; + + // Fabrication du mail + $mail = new CMailFile( + $newsubject, + $sendto, + $from, + $newmessage, + array(), + array(), + array(), + '', + '', + 0, + $msgishtml, + $errorsto + ); + + if ($mail->error) + { + $res=0; + } + if (! $substitutionisok) + { + $mail->error='Some substitution failed'; + $res=0; + } + + // Send Email + if ($res) + { + $res=$mail->sendfile(); + } + + if ($res) + { + // Mail successful + $nbok++; + + dol_syslog("ok for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj2->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + else + { + //if cheack read is use then update prospect contact status + if (strpos($message, '__CHECK_READ__') !== false && ! empty($obj2->source_id)) + { + //Update status communication of thirdparty prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj2->rowid.")"; + dol_syslog("fiche.php: set prospect thirdparty status sql=".$sql, LOG_DEBUG); + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + + //Update status communication of contact prospect + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.rowid=".$obj2->rowid." AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; + dol_syslog("fiche.php: set prospect contact status sql=".$sql, LOG_DEBUG); + + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + } + } + else + { + // Mail failed + $nbko++; + + dol_syslog("error for #".$i.($mail->error?' - '.$mail->error:''), LOG_DEBUG); + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; + $sql.=" SET statut=-1, date_envoi=".$db->idate($now)." WHERE rowid=".$obj2->rowid; + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + + $i++; + } + } + + // Loop finished, set global statut of mail + $statut=2; + if (! $nbko) $statut=3; + + $sql="UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$id; + dol_syslog("update global status sql=".$sql, LOG_DEBUG); + $resql2=$db->query($sql); + if (! $resql2) + { + dol_print_error($db); + } + } + else + { + dol_print_error($db); } } } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 99d54901b419a2ae4924422eac45a9e295f66754..dd22a14913c48e50be67f3f9e44a4db9a9c5dba1 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -125,7 +125,7 @@ class AllTests $suite->addTestSuite('UserTest'); require_once dirname(__FILE__).'/UserGroupTest.php'; $suite->addTestSuite('UserGroupTest'); - require_once dirname(__FILE__).'/BankAccountTest.php'; + require_once dirname(__FILE__).'/BankAccountTest.php'; $suite->addTestSuite('BankAccountTest'); require_once dirname(__FILE__).'/CompanyBankAccountTest.php'; $suite->addTestSuite('CompanyBankAccountTest'); diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index caa02a30538b2ee16ef9e3772c570ef821901ed4..54dba76bd3466e68a66be223487fde2dbf700c77 100755 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -140,7 +140,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $localobject2->initAsSpecimen(); $resultCheck=$localobject2->already_exists(); - print __METHOD__." resultCheck=".$resultCheck."\n"; + print __METHOD__." resultCheck=".$resultCheck."\n"; $this->assertGreaterThan(0, $resultCheck); $resultSecondCreate=$localobject2->create($user); diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php index 76ce0888f251689616fc7db6f83bfde9e8f3f192..4797301b5757fdd9c59e193419c00b02627a0dfd 100755 --- a/test/phpunit/FunctionsTest.php +++ b/test/phpunit/FunctionsTest.php @@ -152,37 +152,37 @@ class FunctionsTest extends PHPUnit_Framework_TestCase } - /** - * testDolTextIsHtml - * - * @return void - */ - public function testDolTextIsHtml() - { - // True - $input='<html>xxx</html>'; - $after=dol_textishtml($input); - $this->assertTrue($after); - $input='<body>xxx</body>'; - $after=dol_textishtml($input); - $this->assertTrue($after); - $input='xxx <b>yyy</b> zzz'; - $after=dol_textishtml($input); - $this->assertTrue($after); - $input='xxx<br>'; - $after=dol_textishtml($input); - $this->assertTrue($after); - $input='text with <div>some div</div>'; - $after=dol_textishtml($input); - $this->assertTrue($after); - $input='text with HTML entities'; - $after=dol_textishtml($input); - $this->assertTrue($after); - - // False - $input='xxx < br>'; - $after=dol_textishtml($input); - $this->assertFalse($after); + /** + * testDolTextIsHtml + * + * @return void + */ + public function testDolTextIsHtml() + { + // True + $input='<html>xxx</html>'; + $after=dol_textishtml($input); + $this->assertTrue($after); + $input='<body>xxx</body>'; + $after=dol_textishtml($input); + $this->assertTrue($after); + $input='xxx <b>yyy</b> zzz'; + $after=dol_textishtml($input); + $this->assertTrue($after); + $input='xxx<br>'; + $after=dol_textishtml($input); + $this->assertTrue($after); + $input='text with <div>some div</div>'; + $after=dol_textishtml($input); + $this->assertTrue($after); + $input='text with HTML entities'; + $after=dol_textishtml($input); + $this->assertTrue($after); + + // False + $input='xxx < br>'; + $after=dol_textishtml($input); + $this->assertFalse($after); } @@ -236,17 +236,17 @@ class FunctionsTest extends PHPUnit_Framework_TestCase } - /** - * testDolNbOfLinesBis - * - * @return boolean - */ - public function testDolNbOfLinesBis() - { + /** + * testDolNbOfLinesBis + * + * @return boolean + */ + public function testDolNbOfLinesBis() + { // This is not a html string so nb of lines depends on \n - $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; - $after=dol_nboflines_bis($input,0); - $this->assertEquals($after,3); + $input="A string\nwith a é, &, < and > and bold tag.\nThird line"; + $after=dol_nboflines_bis($input,0); + $this->assertEquals($after,3); // This is a html string so nb of lines depends on <br> $input="A string\nwith a é, &, < and > and <b>bold</b> tag.\nThird line"; @@ -254,11 +254,11 @@ class FunctionsTest extends PHPUnit_Framework_TestCase $this->assertEquals($after,1); // This is a html string so nb of lines depends on <br> - $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; - $after=dol_nboflines_bis($input,0); - $this->assertEquals($after,3); - - return true; + $input="A string<br>with a é, &, < and > and <b>bold</b> tag.<br>Third line"; + $after=dol_nboflines_bis($input,0); + $this->assertEquals($after,3); + + return true; } @@ -447,11 +447,11 @@ class FunctionsTest extends PHPUnit_Framework_TestCase //var_dump($decoded); $this->assertEquals($arraytotest,$decoded); - $encoded=dol_json_encode($arraytotest); - //var_dump($encoded); - $this->assertEquals('[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]',$encoded); - $decoded=dol_json_decode($encoded,true); - //var_dump($decoded); + $encoded=dol_json_encode($arraytotest); + //var_dump($encoded); + $this->assertEquals('[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]',$encoded); + $decoded=dol_json_decode($encoded,true); + //var_dump($decoded); $this->assertEquals($arraytotest,$decoded); }