From 80a12fcd1cb7fdd995f47eef7a513d75eb1649aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 3 Feb 2019 14:29:45 +0100 Subject: [PATCH 01/77] psr2 Squiz.WhiteSpace.ScopeClosingBrace.Indent --- dev/initdata/generate-order.php | 89 ++-- dev/setup/codesniffer/ruleset.xml | 2 + htdocs/accountancy/admin/accountmodel.php | 4 +- htdocs/accountancy/admin/categories_list.php | 4 +- htdocs/accountancy/admin/journals_list.php | 4 +- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/expensereport/index.php | 4 +- htdocs/accountancy/supplier/index.php | 6 +- htdocs/adherents/class/subscription.class.php | 16 +- htdocs/adherents/stats/geo.php | 15 +- htdocs/adherents/subscription/card.php | 14 +- htdocs/adherents/subscription/list.php | 16 +- htdocs/admin/dict.php | 10 +- htdocs/admin/mailman.php | 10 +- htdocs/admin/menus/edit.php | 8 +- htdocs/admin/receiptprinter.php | 74 +-- htdocs/admin/socialnetworks.php | 21 +- htdocs/admin/website.php | 4 +- htdocs/api/admin/explorer.php | 13 +- htdocs/blockedlog/class/blockedlog.class.php | 4 +- .../categories/class/api_categories.class.php | 60 +-- .../action/class/api_agendaevents.class.php | 46 +- .../mailing/class/advtargetemailing.class.php | 52 +- htdocs/comm/mailing/index.php | 77 ++- .../comm/propal/class/api_proposals.class.php | 131 +++-- htdocs/comm/propal/class/propal.class.php | 14 +- .../comm/propal/tpl/linkedobjectblock.tpl.php | 30 +- htdocs/compta/bank/treso.php | 8 +- htdocs/compta/compta-files.php | 128 ++--- htdocs/compta/facture/fiche-rec.php | 24 +- htdocs/compta/facture/list.php | 10 +- htdocs/compta/paiement/cheque/index.php | 22 +- .../compta/paiement/class/paiement.class.php | 4 +- htdocs/compta/prelevement/bons.php | 152 +++--- htdocs/compta/prelevement/create.php | 8 +- htdocs/compta/stats/cabyuser.php | 81 ++- htdocs/compta/stats/casoc.php | 59 ++- htdocs/contact/class/contact.class.php | 3 +- htdocs/contrat/class/api_contracts.class.php | 10 +- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/class/html.form.class.php | 74 +-- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/class/menubase.class.php | 2 +- htdocs/core/db/sqlite3.class.php | 36 +- htdocs/core/lib/functions.lib.php | 21 +- htdocs/core/lib/pdf.lib.php | 6 +- .../commande/doc/pdf_einstein.modules.php | 27 +- .../commande/doc/pdf_eratosthene.modules.php | 35 +- .../doc/doc_generic_contract_odt.modules.php | 13 +- .../modules/facture/doc/pdf_crabe.modules.php | 50 +- .../facture/doc/pdf_sponge.modules.php | 4 +- htdocs/core/modules/fichinter/mod_arctic.php | 10 +- .../doc/doc_generic_product_odt.modules.php | 17 +- .../project/doc/pdf_beluga.modules.php | 232 ++++----- .../doc/doc_generic_proposal_odt.modules.php | 8 +- .../doc/doc_generic_stock_odt.modules.php | 13 +- .../user/doc/doc_generic_user_odt.modules.php | 10 +- .../doc/doc_generic_usergroup_odt.modules.php | 8 +- htdocs/core/tpl/contacts.tpl.php | 5 +- htdocs/core/tpl/login.tpl.php | 22 +- htdocs/core/tpl/objectline_edit.tpl.php | 58 ++- htdocs/core/tpl/objectline_view.tpl.php | 24 +- .../class/actions_datapolicy.class.php | 3 +- htdocs/datapolicy/class/datapolicy.class.php | 2 +- htdocs/don/tpl/linkedobjectblock.tpl.php | 6 +- .../expedition/class/api_shipments.class.php | 152 +++--- .../class/api_expensereports.class.php | 54 +- htdocs/expensereport/payment/payment.php | 23 +- htdocs/exports/export.php | 2 +- .../class/api_interventions.class.php | 35 +- .../class/fournisseur.commande.class.php | 96 ++-- .../fournisseur.commande.dispatch.class.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/commande/card.php | 418 ++++++++-------- htdocs/fourn/commande/dispatch.php | 36 +- htdocs/index.php | 12 +- htdocs/install/check.php | 30 +- htdocs/modulebuilder/admin/setup.php | 7 +- ..._99_modMyModule_MyModuleTriggers.class.php | 466 +++++++++--------- .../modulebuilder/template/myobject_card.php | 40 +- .../class/multicurrency.class.php | 65 ++- htdocs/product/class/product.class.php | 2 +- .../class/price_expression.class.php | 26 +- .../class/price_global_variable.class.php | 24 +- .../price_global_variable_updater.class.php | 24 +- .../stock/class/api_stockmovements.class.php | 58 +-- .../stock/class/api_warehouses.class.php | 58 +-- htdocs/product/stock/movement_list.php | 19 +- htdocs/projet/card.php | 2 +- htdocs/projet/class/api_projects.class.php | 208 ++++---- htdocs/projet/class/api_tasks.class.php | 140 +++--- htdocs/projet/class/project.class.php | 2 +- .../canvas/company/tpl/card_edit.tpl.php | 5 +- .../canvas/individual/tpl/card_edit.tpl.php | 5 +- htdocs/societe/class/societe.class.php | 7 +- htdocs/societe/list.php | 31 +- htdocs/takepos/takepos.php | 35 +- htdocs/ticket/class/api_tickets.class.php | 4 +- htdocs/user/card.php | 12 +- htdocs/user/clicktodial.php | 12 +- htdocs/variants/combinations.php | 23 +- htdocs/variants/list.php | 6 +- htdocs/webservices/server_contact.php | 12 +- test/phpunit/BuildDocTest.php | 6 +- 104 files changed, 2035 insertions(+), 2058 deletions(-) diff --git a/dev/initdata/generate-order.php b/dev/initdata/generate-order.php index e0adb2a256e..8f8b4e2a2d9 100755 --- a/dev/initdata/generate-order.php +++ b/dev/initdata/generate-order.php @@ -20,8 +20,8 @@ */ /** - * \file dev/initdata/generate-order.php - * \brief Script example to inject random orders (for load tests) + * \file dev/initdata/generate-order.php + * \brief Script example to inject random orders (for load tests) */ // Test si mode batch @@ -113,13 +113,13 @@ $societesid = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)"; $resql=$db->query($sql); if ($resql) { - $num_thirdparties = $db->num_rows($resql); - $i = 0; - while ($i < $num_thirdparties) { - $i++; - $row = $db->fetch_row($resql); - $societesid[$i] = $row[0]; - } + $num_thirdparties = $db->num_rows($resql); + $i = 0; + while ($i < $num_thirdparties) { + $i++; + $row = $db->fetch_row($resql); + $societesid[$i] = $row[0]; + } } else { print "err"; } @@ -127,35 +127,32 @@ $commandesid = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $i++; - $row = $db->fetch_row($resql); - $commandesid[$i] = $row[0]; - } + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $i++; + $row = $db->fetch_row($resql); + $commandesid[$i] = $row[0]; + } } else { print "err"; } $prodids = array(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1"; $resql = $db->query($sql); -if ($resql) -{ - $num_prods = $db->num_rows($resql); - $i = 0; - while ($i < $num_prods) - { - $i++; +if ($resql) { + $num_prods = $db->num_rows($resql); + $i = 0; + while ($i < $num_prods) { + $i++; - $row = $db->fetch_row($resql); - $prodids[$i] = $row[0]; + $row = $db->fetch_row($resql); + $prodids[$i] = $row[0]; } } - print "Build ".GEN_NUMBER_COMMANDE." orders\n"; for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) { @@ -173,18 +170,18 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) $object->cond_reglement_id = mt_rand(0, 2); $object->more_reglement_id = mt_rand(0, 7); $object->availability_id = mt_rand(0, 1); - + $listofuserid=array(12,13,16); - + $fuser = new User($db); $fuser->fetch($listofuserid[mt_rand(0,2)]); $fuser->getRights(); - + $db->begin(); $result=$object->create($fuser); - if ($result >= 0) - { + if ($result >= 0) + { $nbp = mt_rand(2, 5); $xnbp = 0; while ($xnbp < $nbp) @@ -200,23 +197,23 @@ for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++) $xnbp++; } - $result=$object->valid($fuser); - if ($result > 0) - { + $result=$object->valid($fuser); + if ($result > 0) + { $db->commit(); print " OK with ref ".$object->ref."\n"; - } - else - { + } + else + { print " KO\n"; - $db->rollback(); - dol_print_error($db,$object->error); - } - } - else - { + $db->rollback(); + dol_print_error($db,$object->error); + } + } + else + { print " KO\n"; - $db->rollback(); - dol_print_error($db,$object->error); - } + $db->rollback(); + dol_print_error($db,$object->error); + } } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index b5c1ae5b6a9..989e9535297 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -173,6 +173,8 @@ + + diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 637d9548eb9..6a3a8c16812 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -538,8 +538,8 @@ if ($id) elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; print ''; - } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index e18be1b8d60..bb3db6fd0bf 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -495,8 +495,8 @@ if ($id) elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; print ''; - } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index f8f7a5f7a54..8d29d10708d 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -444,8 +444,8 @@ if ($id) elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); else print $valuetoshow; print ''; - } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d61b3c991e4..a5a2a691e8f 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -280,7 +280,7 @@ if (! empty($search_credit)) { if (! empty($search_lettering_code)) { $filter['t.lettering_code'] = $search_lettering_code; $param .= '&search_lettering_code=' . urlencode($search_lettering_code); - } +} if ($action == 'delbookkeeping') { diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 81b1f81416a..d41af13d193 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -326,11 +326,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. dol_syslog('htdocs/accountancy/expensereport/index.php'); $resql = $db->query($sql); if ($resql) { - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); while ($row = $db->fetch_row($resql)) { print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { + for($i = 1; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; } print '' . price($row[13]) . ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index fcc6bbecd81..770f6ec74c9 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -328,15 +328,15 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. while ($row = $db->fetch_row($resql)) { print '' . $row[0] . ''; - for($i = 1; $i <= 12; $i ++) { + for($i = 1; $i <= 12; $i ++) { print '' . price($row[$i]) . ''; } print '' . price($row[13]) . ''; print ''; } - $db->free($resql); + $db->free($resql); } else { - print $db->lasterror(); // Show last sql error + print $db->lasterror(); // Show last sql error } print "\n"; print ''; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 319dbb1f75b..04d54c79b21 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -105,14 +105,14 @@ class Subscription extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; - if ($this->fk_type == null) { -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; -$member=new Adherent($this->db); -$result=$member->fetch($this->fk_adherent); -$type=$member->typeid; -} else { -$type=$this->fk_type; -} + if ($this->fk_type == null) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $type=$member->typeid; + } else { + $type=$this->fk_type; + } $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->dateh)."',"; $sql.= " '".$this->db->idate($this->datef)."',"; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index 1a52c9226f5..c62534ec293 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -157,15 +157,16 @@ if ($mode) 'lastdate'=>$db->jdate($obj->lastdate) ); } - if ($mode == 'memberbyregion') //+ + if ($mode == 'memberbyregion') //+ { - $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), - 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), - 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + $data[]=array( + 'label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), + 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), + 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), + 'nb'=>$obj->nb, + 'lastdate'=>$db->jdate($obj->lastdate) ); - } + } if ($mode == 'memberbystate') { $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 014806a2a2f..31944968632 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -308,17 +308,17 @@ if ($rowid && $action != 'edit') print '
'; print ''; - + // Type print ''; print ''; print ''; // Member diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 7e97752af5d..f4c5cb8bebc 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -459,8 +459,8 @@ while ($i < min($num, $limit)) $adherent->statut=$obj->statut; $adherent->login=$obj->login; $adherent->photo=$obj->photo; - - $adht = new AdherentType($db); + + $adht = new AdherentType($db); $adht->fetch($obj->fk_type); print ''; @@ -471,13 +471,13 @@ while ($i < min($num, $limit)) print ''; if (! $i) $totalarray['nbfield']++; } - // Type - if (! empty($arrayfields['d.fk_type']['checked'])) + // Type + if (! empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (! $i) $totalarray['nbfield']++; } // Lastname diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ee3083410dd..537e79ca6a5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1124,12 +1124,12 @@ if ($id) if ($valuetoshow != '') { print ''; - if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; - elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); - else print $valuetoshow; + if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1,$valuetoshow).''; + elseif (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]); + else print $valuetoshow; print ''; - } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } if ($id == 4) print ''; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 65c7f5e8d68..dc0673cca2d 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -127,7 +127,7 @@ if (($action == 'testsubscribe' || $action == 'testunsubscribe') && ! empty($con if ($action == 'testunsubscribe') { $result=$mailmanspip->del_to_mailman($object); - if ($result < 0) + if ($result < 0) { $error++; setEventMessages($mailmanspip->error,$mailmanspip->errors,'errors'); @@ -160,7 +160,7 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN)) print ''; dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); - + //$link=img_picto($langs->trans("Active"),'tick').' '; $link=''; //$link.=$langs->trans("Disable"); @@ -200,10 +200,10 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN)) '; form_constantes($constantes,2); - + print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - + dol_fiche_end(); print '
'; @@ -213,7 +213,7 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN)) else { dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user'); - + $link='
'; //$link.=img_$langs->trans("Activate") $link.=img_picto($langs->trans("Disabled"),'switch_off'); diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index b16e9047b26..a4ff73b52bd 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -219,12 +219,12 @@ if ($action == 'add') $menu->fk_menu=GETPOST('menuId','int'); } else - { - if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0; - else $menu->fk_menu=-1; + { + if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0; + else $menu->fk_menu=-1; $menu->fk_mainmenu=$mainmenu; $menu->fk_leftmenu=$leftmenu; - } + } $result=$menu->create($user); if ($result > 0) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index b8d92687d84..5a446b868c5 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -68,8 +68,7 @@ if (!function_exists('gzdecode')) { * Action */ -if ($action == 'addprinter' && $user->admin) -{ +if ($action == 'addprinter' && $user->admin) { $error=0; $db->begin(); if (empty($printername)) { @@ -81,8 +80,7 @@ if ($action == 'addprinter' && $user->admin) setEventMessages($langs->trans("PrinterParameterEmpty"), null, 'warnings'); } - if (! $error) - { + if (! $error) { $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); if ($result > 0) $error++; @@ -100,8 +98,7 @@ if ($action == 'addprinter' && $user->admin) $action = ''; } -if ($action == 'deleteprinter' && $user->admin) -{ +if ($action == 'deleteprinter' && $user->admin) { $error=0; $db->begin(); if (empty($printerid)) { @@ -109,8 +106,7 @@ if ($action == 'deleteprinter' && $user->admin) setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) - { + if (! $error) { $result= $printer->DeletePrinter($printerid); if ($result > 0) $error++; @@ -128,8 +124,7 @@ if ($action == 'deleteprinter' && $user->admin) $action = ''; } -if ($action == 'updateprinter' && $user->admin) -{ +if ($action == 'updateprinter' && $user->admin) { $error=0; $db->begin(); if (empty($printerid)) { @@ -137,18 +132,14 @@ if ($action == 'updateprinter' && $user->admin) setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) - { + if (! $error) { $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); if ($result > 0) $error++; - if (! $error) - { + if (! $error) { $db->commit(); setEventMessages($langs->trans("PrinterUpdated",$printername), null); - } - else - { + } else { $db->rollback(); dol_print_error($db); } @@ -156,24 +147,19 @@ if ($action == 'updateprinter' && $user->admin) $action = ''; } -if ($action == 'testprinter' && $user->admin) -{ +if ($action == 'testprinter' && $user->admin) { $error=0; if (empty($printerid)) { $error++; setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors'); } - if (! $error) - { + if (! $error) { // test $ret = $printer->SendTestToPrinter($printerid); - if ($ret == 0) - { + if ($ret == 0) { setEventMessages($langs->trans("TestSentToPrinter", $printername), null); - } - else - { + } else { setEventMessages($printer->error, $printer->errors, 'errors'); } } @@ -181,8 +167,7 @@ if ($action == 'testprinter' && $user->admin) } -if ($action == 'updatetemplate' && $user->admin) -{ +if ($action == 'updatetemplate' && $user->admin) { $error=0; $db->begin(); if (empty($templateid)) { @@ -190,18 +175,14 @@ if ($action == 'updatetemplate' && $user->admin) setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors'); } - if (! $error) - { + if (! $error) { $result= $printer->UpdateTemplate($templatename, $template, $templateid); if ($result > 0) $error++; - if (! $error) - { + if (! $error) { $db->commit(); setEventMessages($langs->trans("TemplateUpdated",$templatename), null); - } - else - { + } else { $db->rollback(); dol_print_error($db); } @@ -223,8 +204,7 @@ print load_fiche_titre($langs->trans("ReceiptPrinterSetup"),$linkback,'title_set $head = receiptprinteradmin_prepare_head($mode); -if ($mode == 'config' && $user->admin) -{ +if ($mode == 'config' && $user->admin) { print ''; print ''; if ($action!='editprinter') { @@ -253,11 +233,9 @@ if ($mode == 'config' && $user->admin) if ($ret > 0) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { - for ($line=0; $line < $nbofprinters; $line++) - { + for ($line=0; $line < $nbofprinters; $line++) { print ''; - if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) - { + if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) { print ''; print ''; $ret = $printer->selectTypePrinter($printer->listprinters[$line]['fk_type']); @@ -269,7 +247,7 @@ if ($mode == 'config' && $user->admin) print ''; print ''; print ''; - } else { + } else { print ''; print ''; print ''; @@ -291,10 +269,8 @@ if ($mode == 'config' && $user->admin) } } - if ($action!='editprinter') - { - if ($nbofprinters > 0) - { + if ($action!='editprinter') { + if ($nbofprinters > 0) { print ''; print ''; print ''; @@ -357,8 +333,7 @@ if ($mode == 'config' && $user->admin) dol_fiche_end(); } -if ($mode == 'template' && $user->admin) -{ +if ($mode == 'template' && $user->admin) { print ''; print ''; if ($action!='edittemplate') { @@ -429,8 +404,7 @@ if ($mode == 'template' && $user->admin) print ''; print "\n"; $max = count($printer->tags); - for ($tag=0; $tag < $max; $tag++) - { + for ($tag=0; $tag < $max; $tag++) { print ''; print ''; print ''; diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index d25becaac4f..688e58f59ad 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -98,17 +98,16 @@ print '
'; $arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook'); -foreach($arrayofsocialnetworks as $snkey => $snlabel) -{ - $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if ($conf->use_javascript_ajax) { - $link = ajax_constantonoff($consttocheck); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); -} - - print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; +foreach($arrayofsocialnetworks as $snkey => $snlabel) { + $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); + if ($conf->use_javascript_ajax) { + $link = ajax_constantonoff($consttocheck); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); + } + + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; } diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 4abcaed9b6a..0053612803e 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -478,8 +478,8 @@ if ($id) } else print $valuetoshow; print ''; - } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; + } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1; } print '
'; $result=$db->query($sql); - if ($result) - { - $num = $db->num_rows($result); + if ($result) { + $num = $db->num_rows($result); - $i = 0; + $i = 0; - while ($i < $num ) - { - $obj = $db->fetch_object($result); - print '
'.$langs->trans("Type").''; - if ( ! empty($object->fk_type) ) { - $adht->fetch($object->fk_type); - print $adht->getNomUrl(1); - } else { - print $langs->trans("NoType"); - } + if (! empty($object->fk_type) ) { + $adht->fetch($object->fk_type); + print $adht->getNomUrl(1); + } else { + print $langs->trans("NoType"); + } print '
'.$subscription->getNomUrl(1).''; - if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); - print ''; + if ( ! empty($obj->fk_type) ) print $adht->getNomUrl(1); + print '
'.$printer->listprinters[$line]['name'].''.$langs->trans($printer->listprinters[$line]['fk_type_name']).''.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'
'.$langs->trans("Name").''.$langs->trans("Type").''.$langs->trans("Description").'
<'.$printer->tags[$tag].'>'.$langs->trans(strtoupper($printer->tags[$tag])).'
'; diff --git a/htdocs/api/admin/explorer.php b/htdocs/api/admin/explorer.php index 951e88f63fc..9714f8d7e64 100644 --- a/htdocs/api/admin/explorer.php +++ b/htdocs/api/admin/explorer.php @@ -89,15 +89,14 @@ foreach ($modulesdir as $dir) $obj = 'facture'; } if ($module == 'ficheinter') { - $obj = 'fichinter'; - $part = 'fichinter'; - $module='fichinter'; - } + $obj = 'fichinter'; + $part = 'fichinter'; + $module='fichinter'; + } - if (empty($conf->$module->enabled)) $enabled=false; + if (empty($conf->$module->enabled)) $enabled=false; - if ($enabled) - { + if ($enabled) { /* * If exists, load the API class for enable module * diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 0d24b71b343..b75da58caba 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -921,8 +921,8 @@ class BlockedLog * @param int $beforeid ID of a record * @return string Hash of previous record (if beforeid is defined) or hash of last record (if beforeid is 0) */ - public function getPreviousHash($withlock = 0, $beforeid = 0) - { + public function getPreviousHash($withlock = 0, $beforeid = 0) + { global $conf; $previoussignature=''; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 843e2fc0ee6..52fca4f3772 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -55,8 +55,8 @@ class Categories extends DolibarrApi */ function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->category = new Categorie($this->db); } @@ -67,25 +67,25 @@ class Categories extends DolibarrApi * * @param int $id ID of category * @return array|mixed data without useless information - * + * * @throws RestException */ function get($id) { - if(! DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->category); + return $this->_cleanObjectDatas($this->category); } /** @@ -101,7 +101,7 @@ class Categories extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of category objects * - * @throws RestException + * @throws RestException */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') { @@ -109,9 +109,9 @@ class Categories extends DolibarrApi $obj_ret = array(); - if(! DolibarrApiAccess::$user->rights->categorie->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as t"; @@ -127,7 +127,7 @@ class Categories extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -145,7 +145,7 @@ class Categories extends DolibarrApi $result = $db->query($sql); if ($result) { - $i=0; + $i=0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -164,7 +164,7 @@ class Categories extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No category found'); } - return $obj_ret; + return $obj_ret; } /** @@ -176,8 +176,8 @@ class Categories extends DolibarrApi function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + throw new RestException(401); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -201,17 +201,17 @@ class Categories extends DolibarrApi function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; @@ -224,7 +224,7 @@ class Categories extends DolibarrApi } else { - throw new RestException(500, $this->category->error); + throw new RestException(500, $this->category->error); } } @@ -237,16 +237,16 @@ class Categories extends DolibarrApi function delete($id) { if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->category->fetch($id); if( ! $result ) { throw new RestException(404, 'category not found'); } - if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (! $this->category->delete(DolibarrApiAccess::$user)) { throw new RestException(401,'error when delete category'); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 1e9dde34bde..88b792507f4 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -58,7 +58,7 @@ class AgendaEvents extends DolibarrApi * * @param int $id ID of Agenda Events * @return array|mixed Data without useless information - * + * * @throws RestException */ function get($id) @@ -83,7 +83,7 @@ class AgendaEvents extends DolibarrApi $result = $this->actioncomm->fetch_optionals(); $this->actioncomm->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->actioncomm); + return $this->_cleanObjectDatas($this->actioncomm); } /** @@ -116,7 +116,7 @@ class AgendaEvents extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $sql = "SELECT t.id as rowid"; if (! empty($conf->societe->enabled)) @@ -160,7 +160,7 @@ class AgendaEvents extends DolibarrApi if ($result) { - $i=0; + $i=0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -179,7 +179,7 @@ class AgendaEvents extends DolibarrApi if ( ! count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } - return $obj_ret; + return $obj_ret; } /** @@ -190,12 +190,12 @@ class AgendaEvents extends DolibarrApi */ function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insuffisant rights to create your Agenda Event"); - } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + throw new RestException(401, "Insuffisant rights to create your Agenda Event"); + } + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -229,21 +229,21 @@ class AgendaEvents extends DolibarrApi /* function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { - throw new RestException(401, "Insuffisant rights to create your Agenda Event"); - } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { - throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + throw new RestException(401, "Insuffisant rights to create your Agenda Event"); + } + if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + } $result = $this->actioncomm->fetch($id); if ( ! $result ) { throw new RestException(404, 'actioncomm not found'); } - if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->actioncomm->$field = $value; @@ -266,13 +266,13 @@ class AgendaEvents extends DolibarrApi function delete($id) { if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { - throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); - } + throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); + } $result = $this->actioncomm->fetch($id); if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { - throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); + throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } if( ! $result ) { diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 0de2efbd9cf..79df55a2bb6 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -875,32 +875,32 @@ class AdvanceTargetingMailing extends CommonObject foreach($extralabels as $key=>$val) { - if (($extrafields->attribute_type[$key] == 'varchar') || - ($extrafields->attribute_type[$key] == 'text')) { - if (!empty($arrayquery['options_'.$key])) { - $sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')"; - } - } elseif (($extrafields->attribute_type[$key] == 'int') || - ($extrafields->attribute_type[$key] == 'double')) { - if (!empty($arrayquery['options_'.$key.'_max'])) { - $sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")"; - } - } elseif (($extrafields->attribute_type[$key] == 'date') || - ($extrafields->attribute_type[$key] == 'datetime')) { - if (!empty($arrayquery['options_'.$key.'_end_dt'])){ - $sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')"; - } - }elseif ($extrafields->attribute_type[$key] == 'boolean') { - if ($arrayquery['options_'.$key]!=''){ - $sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")"; - } - }else{ - if (is_array($arrayquery['options_'.$key])) { - $sqlwhere[]= " (tse.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))"; - } elseif (!empty($arrayquery['options_'.$key])) { - $sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')"; - } - } + if (($extrafields->attribute_type[$key] == 'varchar') + || ($extrafields->attribute_type[$key] == 'text')) { + if (!empty($arrayquery['options_'.$key])) { + $sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')"; + } + } elseif (($extrafields->attribute_type[$key] == 'int') || + ($extrafields->attribute_type[$key] == 'double')) { + if (!empty($arrayquery['options_'.$key.'_max'])) { + $sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")"; + } + } elseif (($extrafields->attribute_type[$key] == 'date') || + ($extrafields->attribute_type[$key] == 'datetime')) { + if (!empty($arrayquery['options_'.$key.'_end_dt'])){ + $sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')"; + } + } elseif ($extrafields->attribute_type[$key] == 'boolean') { + if ($arrayquery['options_'.$key]!=''){ + $sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")"; + } + } else { + if (is_array($arrayquery['options_'.$key])) { + $sqlwhere[]= " (tse.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))"; + } elseif (!empty($arrayquery['options_'.$key])) { + $sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')"; + } + } } } } diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 0c98800b3ea..3b306e04a97 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -109,20 +109,18 @@ if (is_resource($handle)) print '
'.img_object('',$mailmodule->picto).' '.$obj->label.''.$obj->nb.''; - $i++; + while ($i < $num ) { + $obj = $db->fetch_object($result); + print ''.img_object('',$mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + $i++; } - $db->free($result); + $db->free($result); } else { @@ -154,45 +152,42 @@ $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql.= " ORDER BY m.date_creat DESC"; $sql.= " LIMIT ".$limit; $result=$db->query($sql); -if ($result) -{ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +if ($result) { + print '
'.$langs->trans("LastMailings",$limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'; + print ''; + print ''; + print ''; + print ''; + print ''; - $num = $db->num_rows($result); - if ($num > 0) - { - $i = 0; + $num = $db->num_rows($result); + if ($num > 0) { + $i = 0; - while ($i < $num ) - { - $obj = $db->fetch_object($result); + while ($i < $num ) { + $obj = $db->fetch_object($result); - print ''; - print ''; - print ''; - print ''; - print ''; - $mailstatic=new Mailing($db); - print ''; - print ''; - $i++; - } + print ''; + print ''; + print ''; + print ''; + print ''; + $mailstatic=new Mailing($db); + print ''; + print ''; + $i++; + } } - else + else { - print ''; + print ''; } - print "
'.$langs->trans("LastMailings",$limit).''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.''.dol_trunc($obj->titre,38).''.dol_print_date($db->jdate($obj->date_creat),'day').''.($obj->nbemail?$obj->nbemail:"0").''.$mailstatic->LibStatut($obj->statut,5).'
'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.''.dol_trunc($obj->titre,38).''.dol_print_date($db->jdate($obj->date_creat),'day').''.($obj->nbemail?$obj->nbemail:"0").''.$mailstatic->LibStatut($obj->statut,5).'
'.$langs->trans("None").'
'.$langs->trans("None").'

"; - $db->free($result); + print "

"; + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } @@ -207,7 +202,7 @@ if ($langs->file_exists("html/spam.html",0)) { print ''; print '
'; - } +} // End of page llxFooter(); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 6ce38f8c432..07d7fdeba6c 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -184,11 +184,11 @@ class Proposals extends DolibarrApi */ function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { - throw new RestException(401, "Insuffisant rights"); - } - // Check mandatory fields - $result = $this->_validate($request_data); + if(! DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); foreach($request_data as $field => $value) { $this->propal->$field = $value; @@ -218,25 +218,25 @@ class Proposals extends DolibarrApi */ function getLines($id) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->propal->lire) { + throw new RestException(401); + } - $result = $this->propal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Commercial Proposal not found'); - } + $result = $this->propal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commercial Proposal not found'); + } - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->propal->getLinesArray(); - $result = array(); - foreach ($this->propal->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; - } + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->propal->getLinesArray(); + $result = array(); + foreach ($this->propal->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } /** * Add a line to given commercial proposal @@ -266,7 +266,7 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; - $updateRes = $this->propal->addline( + $updateRes = $this->propal->addline( $request_data->desc, $request_data->subprice, $request_data->qty, @@ -293,15 +293,14 @@ class Proposals extends DolibarrApi $request_data->origin_id, $request_data->multicurrency_subprice, $request_data->fk_remise_except - ); + ); - if ($updateRes > 0) { - return $updateRes; - } - else { - throw new RestException(400, $this->propal->error); - } - } + if ($updateRes > 0) { + return $updateRes; + } else { + throw new RestException(400, $this->propal->error); + } + } /** * Update a line of given commercial proposal @@ -360,14 +359,14 @@ class Proposals extends DolibarrApi isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice - ); + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; } /** @@ -386,7 +385,7 @@ class Proposals extends DolibarrApi function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->propal->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->propal->fetch($id); @@ -417,12 +416,12 @@ class Proposals extends DolibarrApi * @param array $request_data Datas * * @return int - */ + */ function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401); + } $result = $this->propal->fetch($id); if( ! $result ) { @@ -654,35 +653,35 @@ class Proposals extends DolibarrApi */ function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { - throw new RestException(401); - } - $result = $this->propal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Commercial Proposal not found'); - } + if(! DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401); + } + $result = $this->propal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Commercial Proposal not found'); + } - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->propal->classifyBilled(DolibarrApiAccess::$user ); - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->propal->error); - } + $result = $this->propal->classifyBilled(DolibarrApiAccess::$user ); + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->propal->error); + } - $result = $this->propal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Proposal not found'); - } + $result = $this->propal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Proposal not found'); + } - if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->propal->fetchObjectLinked(); + $this->propal->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->propal); + return $this->_cleanObjectDatas($this->propal); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b3da0634aee..3d51768106c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1063,13 +1063,13 @@ class Propal extends CommonObject for ($i=0;$i<$num;$i++) { if (! is_object($this->lines[$i])) // If this->lines is not array of objects, coming from REST API - { // Convert into object this->lines[$i]. - $line = (object) $this->lines[$i]; - } - else - { - $line = $this->lines[$i]; - } + { // Convert into object this->lines[$i]. + $line = (object) $this->lines[$i]; + } + else + { + $line = $this->lines[$i]; + } // Reset fk_parent_line for line that are not child lines or special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 118bc3fbd37..5ad537c16b7 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -24,10 +24,9 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; +if (empty($conf) || ! is_object($conf)) { + print "Error, template page can't be called as URL"; + exit; } ?> @@ -54,21 +53,22 @@ foreach($linkedObjectBlock as $key => $objectlink) ?> trans("Proposal"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) - { - $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; - print '
'; - } - ?> + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + { + $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; + print ' '; + } + ?> getNomUrl(1); ?> ref_client; ?> date,'day'); ?> rights->propale->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->propale->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> @@ -86,7 +86,7 @@ if (count($linkedObjectBlock) > 1) - diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 7ad92a012b1..d94291dd106 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -3,7 +3,7 @@ * Copyright (C) 2008-2009 Laurent Destailleur (Eldy) * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2015 Marcos García + * Copyright (C) 2016 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -183,13 +183,13 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) foreach($sqls as $sql){ $resql = $db->query($sql); - if($resql){ - while($sqlobj = $db->fetch_object($resql)){ + if ($resql) { + while ($sqlobj = $db->fetch_object($resql)) { $tab_sqlobj[] = $sqlobj; $tab_sqlobjOrder[]= $db->jdate($sqlobj->dlr); } $db->free($resql); - }else{ + } else { $error++; } } diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 5cce413a9ae..e524d6e26e1 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -112,16 +112,16 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ if ($resd) { - $numd = $db->num_rows($resd); + $numd = $db->num_rows($resd); - $tmpinvoice=new Facture($db); - $tmpinvoicesupplier=new FactureFournisseur($db); - $tmpdonation=new Don($db); + $tmpinvoice=new Facture($db); + $tmpinvoicesupplier=new FactureFournisseur($db); + $tmpdonation=new Don($db); - $upload_dir =''; - $i=0; - while($i<$numd) - { + $upload_dir =''; + $i=0; + while($i<$numd) + { $objd = $db->fetch_object($resd); switch($objd->item) @@ -197,14 +197,14 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ } } $i++; - } - } - else - { - dol_print_error($db); - } + } + } + else + { + dol_print_error($db); + } - $db->free($resd); + $db->free($resd); } /* @@ -315,57 +315,57 @@ if (!empty($date_start) && !empty($date_stop)) if ($result) { $TData = dol_sort_array($filesarray, 'date', 'ASC'); - if(empty($TData)) { - print ''.$langs->trans("NoItem").''; - } else { - // Sort array by date ASC to calucalte balance + if(empty($TData)) { + print ''.$langs->trans("NoItem").''; + } else { + // Sort array by date ASC to calucalte balance - $totalDebit = 0; - $totalCredit = 0; - // Balance calculation - $balance = 0; - foreach($TData as &$data1) { - if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ - $data1['amount']=-$data1['amount']; - } - if ($data1['amount']>0){ - }else{ - } - $balance += $data1['amount']; - $data1['balance'] = $balance; - } - // Display array - foreach($TData as $data) { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; - print ""; - print dol_print_date($data['date'],'day'); - print "\n"; - print ''.$data['item'].''; - print ''.$data['ref'].''; - - // File link - print '".$data['name']."\n"; - - print ''.$data['paid'].''; - print ''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."\n"; - $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; - print ''.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."\n"; - $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); - // Balance - print ''.price($data['balance'])."\n"; - print "\n"; - } - print ''; - print ' '; - print ''.price($totalDebit).''; - print ''.price($totalCredit).''; - print ''.price(price2num($totalDebit - $totalCredit, 'MT')).''; - print "\n"; - } + $totalDebit = 0; + $totalCredit = 0; + // Balance calculation + $balance = 0; + foreach($TData as &$data1) { + if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ + $data1['amount']=-$data1['amount']; + } + if ($data1['amount']>0){ + }else{ + } + $balance += $data1['amount']; + $data1['balance'] = $balance; } + // Display array + foreach($TData as $data) { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; + print ""; + print dol_print_date($data['date'],'day'); + print "\n"; + print ''.$data['item'].''; + print ''.$data['ref'].''; + + // File link + print '".$data['name']."\n"; + + print ''.$data['paid'].''; + print ''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."\n"; + $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; + print ''.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."\n"; + $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + // Balance + print ''.price($data['balance'])."\n"; + print "\n"; + } + print ''; + print ' '; + print ''.price($totalDebit).''; + print ''.price($totalCredit).''; + print ''.price(price2num($totalDebit - $totalCredit, 'MT')).''; + print "\n"; + } + } print ""; print ''; } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index c0dd351f009..c0896db8326 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -837,12 +837,12 @@ if (empty($reshook)) $type = GETPOST('type'); $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - // Check parameters - if (GETPOST('type') < 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error ++; - } + // Check parameters + if (GETPOST('type') < 0) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $error ++; } + } if ($qty < 0) { $langs->load("errors"); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); @@ -1481,13 +1481,13 @@ else } else { - if ($object->frequency > 0) - { - print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); - } - else - { - print $langs->trans("NotARecurringInvoiceTemplate"); + if ($object->frequency > 0) + { + print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); + } + else + { + print $langs->trans("NotARecurringInvoiceTemplate"); } } print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c3aeb8f6608..d1f08e891af 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -582,12 +582,12 @@ if ($resql) } if ($user->rights->facture->supprimer) { if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { - $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); } - elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation - $arrayofmassactions['predelete'] = $langs->trans("Delete"); - } - } + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 1748a3fa9d2..cfb5205ba8a 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -66,22 +66,20 @@ print ''; print ''.$langs->trans("BankChecks")."\n"; print "\n"; -if ($resql) -{ - if ($row = $db->fetch_row($resql) ) - { - $num = $row[0]; +if ($resql) { + if ($row = $db->fetch_row($resql) ) { + $num = $row[0]; } - print ''; - print ''.$langs->trans("BankChecksToReceipt").''; - print ''; - print ''.$num.''; - print ''; - print "\n"; + print ''; + print ''.$langs->trans("BankChecksToReceipt").''; + print ''; + print ''.$num.''; + print ''; + print "\n"; } else { - dol_print_error($db); + dol_print_error($db); } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 0003043fef4..89b7f01f881 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -551,8 +551,8 @@ class Paiement extends CommonObject { $this->db->rollback(); return -1; - } - // End call triggers + } + // End call triggers } // Delete payment (into paiement_facture and paiement) diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index cfe2e2a942c..d8e454bd3e1 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -88,8 +88,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { - $page = 0; - $offset = 0; + $page = 0; + $offset = 0; } } @@ -98,89 +98,89 @@ $sql.= $db->plimit($limit + 1,$offset); $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - $urladd= "&statut=".$statut; + $urladd= "&statut=".$statut; - $selectedfields=''; + $selectedfields=''; - $newcardbutton=''; - if ($user->rights->prelevement->bons->creer) - { - $newcardbutton = ''.$langs->trans('NewStandingOrder').''; - $newcardbutton.= ''; - $newcardbutton.= ''; - } - - // Lines of title fields - print ''; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); - - $moreforfilter=''; - - print '
'; - print ''."\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder); - print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder); - print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; - print "\n"; - - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($result); - - print '\n"; - - print '\n"; - - print '\n"; - - print ''; - - print ''."\n"; - - print "\n"; - $i++; + $newcardbutton=''; + if ($user->rights->prelevement->bons->creer) + { + $newcardbutton = ''.$langs->trans('NewStandingOrder').''; + $newcardbutton.= ''; + $newcardbutton.= ''; } - print "
  '; - $searchpicto=$form->showFilterButtons(); - print $searchpicto; - print '
'; - - print ''.$obj->ref."'.dol_print_date($db->jdate($obj->datec),'day')."'.price($obj->amount)."'; - print $bon->LibStatut($obj->statut, 3); - print '
"; - print '
'; - print ''; + // Lines of title fields + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - $db->free($result); + print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); + + $moreforfilter=''; + + print '
'; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder); + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder); + print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder); + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; + print "\n"; + + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($result); + + print '\n"; + + print '\n"; + + print '\n"; + + print ''; + + print ''."\n"; + + print "\n"; + $i++; + } + print "
  '; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; + + print ''.$obj->ref."'.dol_print_date($db->jdate($obj->datec),'day')."'.price($obj->amount)."'; + print $bon->LibStatut($obj->statut, 3); + print '
"; + print '
'; + + print '
'; + + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } // End of page diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 2c542f9bad0..cdade0bb079 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -162,9 +162,9 @@ if ($nb) { } else { print '' . $langs->trans("CreateAll") . "\n"; } - } - else - { + } + else + { if ($mysoc->isInEEC()) { print ''.$langs->trans("CreateForSepaFRST")."\n"; @@ -178,7 +178,7 @@ if ($nb) { } else { - print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."\n"; + print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."\n"; } print "\n"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 397538d2ac1..8577ed96c4c 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -57,8 +57,7 @@ $date_startday = GETPOST("date_startday"); $date_endyear = GETPOST("date_endyear"); $date_endmonth = GETPOST("date_endmonth"); $date_endday = GETPOST("date_endday"); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y",dol_now()); $month_current = strftime("%m",dol_now()); $year_start = $year_current; @@ -211,7 +210,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql.= " WHERE f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; - } else { + } else { $sql.= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { @@ -243,12 +242,12 @@ if ($result) { $i=0; while ($i < $num) { $obj = $db->fetch_object($result); - $amount_ht[$obj->rowid] = $obj->amount; - $amount[$obj->rowid] = $obj->amount_ttc; - $name[$obj->rowid] = $obj->name.' '.$obj->firstname; - $catotal_ht+=$obj->amount; - $catotal+=$obj->amount_ttc; - $i++; + $amount_ht[$obj->rowid] = $obj->amount; + $amount[$obj->rowid] = $obj->amount_ttc; + $name[$obj->rowid] = $obj->name.' '.$obj->firstname; + $catotal_ht+=$obj->amount; + $catotal+=$obj->amount_ttc; + $i++; } } else { dol_print_error($db); @@ -302,7 +301,7 @@ print_liste_field_titre( "", $sortfield, $sortorder - ); +); if ($modecompta == 'CREANCES-DETTES') { print_liste_field_titre( $langs->trans('AmountHT'), @@ -313,8 +312,8 @@ if ($modecompta == 'CREANCES-DETTES') { 'align="right"', $sortfield, $sortorder - ); - } else { + ); +} else { print_liste_field_titre(''); } print_liste_field_titre( @@ -326,7 +325,7 @@ print_liste_field_titre( 'align="right"', $sortfield, $sortorder - ); +); print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"],"amount_ttc", @@ -335,7 +334,7 @@ print_liste_field_titre( 'align="right"', $sortfield, $sortorder - ); +); print_liste_field_titre( $langs->trans("OtherStatistics"), $_SERVER["PHP_SELF"], @@ -343,7 +342,7 @@ print_liste_field_titre( "", "", 'align="center" width="20%"' - ); +); print "\n"; if (count($amount)) { @@ -390,22 +389,22 @@ if (count($amount)) { } print "".$linkname."\n"; - // Amount w/o VAT + // Amount w/o VAT print ''; if ($modecompta != 'CREANCES-DETTES') { if ($key > 0) { - print ''; - } else { - print ''; - } + print ''; + } else { + print ''; + } } else { if ($key > 0) { - print ''; - } else { - print ''; - } - print price($amount_ht[$key]); + print ''; + } else { + print ''; + } + print price($amount_ht[$key]); } print ''; @@ -413,16 +412,16 @@ if (count($amount)) { print ''; if ($modecompta != 'CREANCES-DETTES') { if ($key > 0) { - print ''; - } else { - print ''; - } + print ''; + } else { + print ''; + } } else { if ($key > 0) { - print ''; - } else { - print ''; - } + print ''; + } else { + print ''; + } } print price($amount[$key]); print ''; @@ -433,14 +432,14 @@ if (count($amount)) { // Other stats print ''; if (! empty($conf->propal->enabled) && $key>0) { - print ' '.img_picto($langs->trans("ProposalStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("ProposalStats"),"stats").' '; + } if (! empty($conf->commande->enabled) && $key>0) { - print ' '.img_picto($langs->trans("OrderStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("OrderStats"),"stats").' '; + } if (! empty($conf->facture->enabled) && $key>0) { - print ' '.img_picto($langs->trans("InvoiceStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("InvoiceStats"),"stats").' '; + } print ''; print "\n"; $i++; @@ -450,9 +449,9 @@ if (count($amount)) { print ''; print ''.$langs->trans("Total").''; if ($modecompta != 'CREANCES-DETTES') { - print ''; + print ''; } else { - print ''.price($catotal_ht).''; + print ''.price($catotal_ht).''; } print ''.price($catotal).''; print ' '; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 727f65a8b68..5ac640b3b54 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -74,8 +74,7 @@ $date_startday = GETPOST("date_startday",'alpha'); $date_endyear = GETPOST("date_endyear",'alpha'); $date_endmonth = GETPOST("date_endmonth",'alpha'); $date_endday = GETPOST("date_endday",'alpha'); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y",dol_now()); $month_current = strftime("%m",dol_now()); $year_start = $year_current; @@ -451,9 +450,9 @@ if ($modecompta == 'CREANCES-DETTES') { 'align="right"', $sortfield, $sortorder - ); - } else { - print_liste_field_titre(''); + ); +} else { + print_liste_field_titre(''); } print_liste_field_titre( $langs->trans("AmountTTC"), @@ -464,7 +463,7 @@ print_liste_field_titre( 'align="right"', $sortfield, $sortorder - ); +); print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"], @@ -474,7 +473,7 @@ print_liste_field_titre( 'align="right"', $sortfield, $sortorder - ); +); print_liste_field_titre( $langs->trans("OtherStatistics"), $_SERVER["PHP_SELF"], @@ -482,7 +481,7 @@ print_liste_field_titre( "", "", 'align="center" width="20%"' - ); +); print "\n"; @@ -569,34 +568,34 @@ if (count($amount)) { // Amount w/o VAT print ''; if ($modecompta != 'CREANCES-DETTES') { - if ($key > 0) { - print ''; + if ($key > 0) { + print ''; } else { - print ''; - } + print ''; + } } else { if ($key > 0) { - print ''; + print ''; } else { - print ''; + print ''; } - print price($amount_ht[$key]); + print price($amount_ht[$key]); } print ''; // Amount with VAT print ''; if ($modecompta != 'CREANCES-DETTES') { - if ($key > 0) { - print ''; + if ($key > 0) { + print ''; } else { - print ''; + print ''; } } else { - if ($key > 0) { - print ''; + if ($key > 0) { + print ''; } else { - print ''; + print ''; } } print price($amount[$key]); @@ -609,18 +608,18 @@ if (count($amount)) { // Other stats print ''; if (! empty($conf->propal->enabled) && $key>0) { - print ' '.img_picto($langs->trans("ProposalStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("ProposalStats"),"stats").' '; + } if (! empty($conf->commande->enabled) && $key>0) { - print ' '.img_picto($langs->trans("OrderStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("OrderStats"),"stats").' '; + } if (! empty($conf->facture->enabled) && $key>0) { - print ' '.img_picto($langs->trans("InvoiceStats"),"stats").' '; - } + print ' '.img_picto($langs->trans("InvoiceStats"),"stats").' '; + } print ''; - print "\n"; - $i++; - } + print "\n"; + $i++; + } // Total print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index bd7819ee299..484d074ea0a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1010,7 +1010,8 @@ class Contact extends CommonObject } // Removed extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { // For avoid conflicts if trigger used + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { + // For avoid conflicts if trigger used $result=$this->deleteExtraFields($this); if ($result < 0) $error++; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 8631becc515..b09752012d4 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -186,9 +186,9 @@ class Contracts extends DolibarrApi */ function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401, "Insuffisant rights"); - } + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401, "Insuffisant rights"); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -220,9 +220,9 @@ class Contracts extends DolibarrApi */ function getLines($id) { - if(! DolibarrApiAccess::$user->rights->contrat->lire) { + if (! DolibarrApiAccess::$user->rights->contrat->lire) { throw new RestException(401); - } + } $result = $this->contract->fetch($id); if( ! $result ) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4f1d1d21c02..9abf23ff7b1 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5434,8 +5434,7 @@ abstract class CommonObject elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type)) { $morecss = 'maxwidth75'; - }elseif ($type == 'url') - { + } elseif ($type == 'url') { $morecss='minwidth400'; } elseif ($type == 'boolean') diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9401dce5622..a8e8ca85a6b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1470,43 +1470,43 @@ class Form $contactstatic->id=$obj->rowid; $contactstatic->lastname=$obj->lastname; $contactstatic->firstname=$obj->firstname; - if ($obj->statut == 1){ - if ($htmlname != 'none') - { - $disabled=0; - if (is_array($exclude) && count($exclude) && in_array($obj->rowid,$exclude)) $disabled=1; - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; - if (!empty($selected) && in_array($obj->rowid, $selected)) - { - $out.= ''; - } - else - { - $out.= ''; - } - } - else - { - if (in_array($obj->rowid, $selected)) - { - $out.= $contactstatic->getFullName($langs); - if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')'; - if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')'; - } - } - } + if ($obj->statut == 1) { + if ($htmlname != 'none') + { + $disabled=0; + if (is_array($exclude) && count($exclude) && in_array($obj->rowid,$exclude)) $disabled=1; + if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; + if (!empty($selected) && in_array($obj->rowid, $selected)) + { + $out.= ''; + } + else + { + $out.= ''; + } + } + else + { + if (in_array($obj->rowid, $selected)) + { + $out.= $contactstatic->getFullName($langs); + if ($showfunction && $obj->poste) $out.= ' ('.$obj->poste.')'; + if (($showsoc > 0) && $obj->company) $out.= ' - ('.$obj->company.')'; + } + } + } $i++; } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8261b737e43..9f6534558e8 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1346,7 +1346,7 @@ class FormFile print 'browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"').'>'; print ''; } - } + } } else { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 6d6f8471721..67c67aa2e41 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -712,5 +712,5 @@ class Menubase $this->recur($tab, $tab[$x]['rowid'], ($level+1)); } } - } + } } diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 18dfece171c..3d6fad1e588 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -1403,32 +1403,28 @@ class DoliDBSqlite3 extends DoliDB $weekday=self::calc_weekday($first_daynr, !$monday_first); $calc_year=$year; - if ($month == 1 && $day <= 7-$weekday) - { + if ($month == 1 && $day <= 7-$weekday) { if (!$week_year && (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4))) return 0; $week_year= 1; $calc_year--; $first_daynr-= ($days=self::calc_days_in_year($calc_year)); $weekday= ($weekday + 53*7- $days) % 7; - } - - if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { - $days= $daynr - ($first_daynr+ (7-$weekday)); - } - else { - $days= $daynr - ($first_daynr - $weekday); - } - - if ($week_year && $days >= 52*7) - { - $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; - if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) - { - $calc_year++; - return 1; } - } - return floor($days/7+1); + + if (($first_weekday && $weekday != 0) || (!$first_weekday && $weekday >= 4)) { + $days= $daynr - ($first_daynr+ (7-$weekday)); + } else { + $days= $daynr - ($first_daynr - $weekday); + } + + if ($week_year && $days >= 52*7) { + $weekday= ($weekday + self::calc_days_in_year($calc_year)) % 7; + if ((!$first_weekday && $weekday < 4) || ($first_weekday && $weekday == 0)) { + $calc_year++; + return 1; + } + } + return floor($days/7+1); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 52e5257907d..7ec211fa830 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2365,15 +2365,18 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli {//ex: +66_A_BCD_EF_GHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3); } - } + } elseif (strtoupper($countrycode) == "MU") - {//Maurice + { + //Maurice if(dol_strlen($phone) == 11) - {//ex: +230_ABC_DE_FG + { + //ex: +230_ABC_DE_FG $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); } elseif(dol_strlen($phone) == 12) - {//ex: +230_ABCD_EF_GH + { + //ex: +230_ABCD_EF_GH $newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); } } @@ -2514,9 +2517,11 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli } } elseif(strtoupper($countrycode) == "AU") - {//Australie - if(dol_strlen($phone) == 12) - {//ex: +61_A_BCDE_FGHI + { + //Australie + if(dol_strlen($phone) == 12) + { + //ex: +61_A_BCDE_FGHI $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4); } } @@ -2593,7 +2598,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli $rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone; if ($adddivfloat) $rep.=''; else $rep.=''; - } + } return $rep; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dba52f5c69e..5e5b9c71a8f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -900,7 +900,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // First line of company infos $line1=""; $line2=""; $line3=""; $line4=""; - if ($showdetails == 1 || $showdetails == 3) + if ($showdetails == 1 || $showdetails == 3) { // Company name if ($fromcompany->name) @@ -1969,9 +1969,9 @@ function pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails = 0) } else $result.=price($sign * $total_ht, 0, $outputlangs); - } + } } - return $result; + return $result; } /** diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 879319db2b9..679d4a10c20 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -768,23 +768,22 @@ class pdf_einstein extends ModelePDFCommandes $posy=$pdf->GetY()+1; } - // Show payment mode + // Show payment mode if ($object->mode_reglement_code - && $object->mode_reglement_code != 'CHQ' - && $object->mode_reglement_code != 'VIR') - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentMode").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); - $posy=$pdf->GetY()+2; - } + $posy=$pdf->GetY()+2; + } // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a67327fa249..9cf1f9bb263 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -828,30 +828,29 @@ class pdf_eratosthene extends ModelePDFCommandes $posy=$pdf->GetY()+1; } - // Show payment mode + // Show payment mode if ($object->mode_reglement_code - && $object->mode_reglement_code != 'CHQ' - && $object->mode_reglement_code != 'VIR') - { - $pdf->SetFont('','B', $default_font_size - 2); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentMode").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') { + $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posxval, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posxval, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); - $posy=$pdf->GetY()+2; - } + $posy=$pdf->GetY()+2; + } - // Show payment mode CHQ + // Show payment mode CHQ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') { - // Si mode reglement non force ou si force a CHQ - if (! empty($conf->global->FACTURE_CHQ_NUMBER)) - { + // Si mode reglement non force ou si force a CHQ + if (! empty($conf->global->FACTURE_CHQ_NUMBER)) + { if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 399bdca0fe0..b9bb0e97c79 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -294,12 +294,13 @@ class doc_generic_contract_odt extends ModelePDFContract if (! empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $socobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8e2b5a8b198..f1e381ba22b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1286,37 +1286,37 @@ class pdf_crabe extends ModelePDFFactures //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + foreach( $this->localtax2 as $localtax_type => $localtax_rate ) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach( $localtax_rate as $tvakey => $tvaval ) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach( $localtax_rate as $tvakey => $tvaval ) + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/',$tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/',$tvakey)) - { - $tvakey=str_replace('*','',$tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey),1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey),1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } - //} + } } + //} // Revenue stamp if (price2num($object->revenuestamp) != 0) diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 203711fc80f..84601b09f01 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1377,8 +1377,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } - //} - } + } + //} // Revenue stamp if (price2num($object->revenuestamp) != 0) diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 0b1932013cf..b7d25d5b94c 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php'; */ class mod_arctic extends ModeleNumRefFicheinter { - /** + /** * Dolibarr version of the loaded document * @public string */ @@ -130,7 +130,7 @@ class mod_arctic extends ModeleNumRefFicheinter require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; - // On d�fini critere recherche compteur + // On défini critere recherche compteur $mask=$conf->global->FICHINTER_ARTIC_MASK; if (! $mask) @@ -142,14 +142,14 @@ class mod_arctic extends ModeleNumRefFicheinter $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec); return $numFinal; - } + } /** - * Return next free value + * Return next free value * * @param Societe $objsoc Object third party - * @param Object $objforref Object for number to search + * @param Object $objforref Object for number to search * @return string Next free value */ function getNumRef($objsoc, $objforref) diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 8ae2fe0eb9a..25bafee3e2f 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2012 Juanjo Menent +/* Copyright (C) 2010-2012 Laurent Destailleur + * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -321,12 +321,13 @@ class doc_generic_product_odt extends ModelePDFProduct if (! empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $socobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 32a2d10f72d..9d5f7bf75e8 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -425,26 +425,26 @@ class pdf_beluga extends ModelePDFProjects $total_ttc = 0; $num = count($elementarray); - // Loop on each lines - for ($i = 0; $i < $num; $i ++) - { - $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - $pdf->SetTextColor(0,0,0); + // Loop on each lines + for ($i = 0; $i < $num; $i ++) + { + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); - $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); - // Description of line - $idofelement=$elementarray[$i]; - if ($classname == 'ExpenseReport') - { - // We get id of expense report - $expensereportline=new ExpenseReportLine($this->db); - $expensereportline->fetch($idofelement); - $idofelement = $expensereportline->fk_expensereport; - } + // Description of line + $idofelement=$elementarray[$i]; + if ($classname == 'ExpenseReport') + { + // We get id of expense report + $expensereportline=new ExpenseReportLine($this->db); + $expensereportline->fetch($idofelement); + $idofelement = $expensereportline->fk_expensereport; + } $element = new $classname($this->db); $element->fetch($idofelement); @@ -457,114 +457,114 @@ class pdf_beluga extends ModelePDFProjects $qualifiedfortotal = false; // Replacement invoice } - $showpricebeforepagebreak=1; + $showpricebeforepagebreak=1; - $pdf->startTransaction(); - // Label - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter=$pdf->getPage(); - if ($pageposafter > $pageposbefore) // There is a pagebreak - { - $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - // Label - $pdf->SetXY($this->posxref, $curY); - $posybefore=$pdf->GetY(); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text - { - if ($i == ($num-1)) // No more lines, and no space left to show total, so we create a new page - { - $pdf->AddPage('','',true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); - } - } - else - { - // We found a page break - $showpricebeforepagebreak=0; - $forcedesconsamepage=1; - if ($forcedesconsamepage) - { - $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $pdf->startTransaction(); + // Label + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + // Label + $pdf->SetXY($this->posxref, $curY); + $posybefore=$pdf->GetY(); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($num-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + $forcedesconsamepage=1; + if ($forcedesconsamepage) + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $pdf->AddPage('','',true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0,0,0); + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $curY = $tab_top_newpage + $heightoftitleline + 1; - // Label - $pdf->SetXY($this->posxref, $curY); - $posybefore=$pdf->GetY(); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); - } - } - //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); - } - else // No pagebreak - { - $pdf->commitTransaction(); - } - $posYAfterDescription=$pdf->GetY(); + // Label + $pdf->SetXY($this->posxref, $curY); + $posybefore=$pdf->GetY(); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + } + } + //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); - $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); - $pdf->setPage($pageposbefore); - $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - // We suppose that a too long description is moved completely on next page - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; - } + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + } - $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut - // Date - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') - $date = $element->date_commande; - else { - $date = $element->date; - if (empty($date)) - $date = $element->datep; - if (empty($date)) - $date = $element->date_contrat; - if (empty($date)) - $date = $element->datev; // Fiche inter - } + // Date + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + $date = $element->date_commande; + else { + $date = $element->date; + if (empty($date)) + $date = $element->datep; + if (empty($date)) + $date = $element->date_contrat; + if (empty($date)) + $date = $element->datev; // Fiche inter + } - $pdf->SetXY($this->posxdate, $curY); - $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); - $pdf->SetXY($this->posxsociety, $curY); - if ($classname == 'ExpenseReport') - { - $fuser=new User($this->db); - $fuser->fetch($element->fk_user_author); - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); - } - else - { - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L'); - } + $pdf->SetXY($this->posxsociety, $curY); + if ($classname == 'ExpenseReport') + { + $fuser=new User($this->db); + $fuser->fetch($element->fk_user_author); + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); + } + else + { + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty)?$element->thirdparty->name:''), 1, 'L'); + } // Amount without tax if (empty($value['disableamount'])) { diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index cfb1b87388f..bc8bd36e4a7 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -336,10 +336,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index b4fb70c735e..3d6adea87ff 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -321,12 +321,13 @@ class doc_generic_stock_odt extends ModelePDFStock if (! empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $socobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 4a57a1e12cc..7e8eb1a6e3d 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -65,7 +65,7 @@ class doc_generic_user_odt extends ModelePDFUser global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main","companies")); $this->db = $db; $this->name = "ODT templates"; @@ -318,10 +318,10 @@ class doc_generic_user_odt extends ModelePDFUser // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 5e1418f8ed2..9a808250770 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -320,10 +320,10 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index c53d30a10c8..06d78607cd6 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -235,7 +235,10 @@ if ($permission) { - + diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 4f50f55b4ba..2a8c5126910 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -21,10 +21,9 @@ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) -{ - print "Error, template page can't be called as URL"; - exit; +if (empty($conf) || ! is_object($conf)) { + print "Error, template page can't be called as URL"; + exit; } @@ -61,19 +60,24 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable $colorbackhmenu1='60,70,100'; // topmenu if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1=$colorbackhmenu1; -$colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); +$colorbackhmenu1 =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); $colorbackhmenu1=join(',',colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' ?> -global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { +global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { // For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random' - ?> +?> - + global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> - + dol_use_jmobile)) { ?> '."\n"; - } + if (! empty($conf->use_javascript_ajax)) { + print "\n".'\n"; + } print load_fiche_titre($langs->trans("DoPayment")); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 858db46b3f5..d5266d8d07c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -806,7 +806,7 @@ if ($step == 3 && $datatoexport) $tablename=getablenamefromfield($code,$sqlmaxforexport); $htmltext =''.$langs->trans("Name").': '.$text.'
'; - if (! empty($objexport->array_export_special[0][$code])) + if (! empty($objexport->array_export_special[0][$code])) { $htmltext.=''.$langs->trans("ComputedField")." -> ".$langs->trans("Method")." : ".$objexport->array_export_special[0][$code]."
"; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 1d7e4b9f939..cfeb62e52e3 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -191,9 +191,9 @@ class Interventions extends DolibarrApi */ function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { - throw new RestException(401, "Insuffisant rights"); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { + throw new RestException(401, "Insuffisant rights"); + } // Check mandatory fields $result = $this->_validate($request_data); foreach($request_data as $field => $value) { @@ -254,8 +254,8 @@ class Interventions extends DolibarrApi function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { - throw new RestException(401, "Insuffisant rights"); - } + throw new RestException(401, "Insuffisant rights"); + } // Check mandatory fields $result = $this->_validateLine($request_data); @@ -267,9 +267,9 @@ class Interventions extends DolibarrApi throw new RestException(404, 'Intervention not found'); } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $updateRes = $this->fichinter->addLine( DolibarrApiAccess::$user, @@ -280,10 +280,9 @@ class Interventions extends DolibarrApi ); if ($updateRes > 0) { - return $updateRes; - } - else { - throw new RestException(400, $this->fichinter->error); + return $updateRes; + } else { + throw new RestException(400, $this->fichinter->error); } } @@ -337,8 +336,8 @@ class Interventions extends DolibarrApi function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { - throw new RestException(401, "Insuffisant rights"); - } + throw new RestException(401, "Insuffisant rights"); + } $result = $this->fichinter->fetch($id); if( ! $result ) { throw new RestException(404, 'Intervention not found'); @@ -350,10 +349,10 @@ class Interventions extends DolibarrApi $result = $this->fichinter->setValid(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); + throw new RestException(304, 'Error nothing done. May be object is already validated'); } if ($result < 0) { - throw new RestException(500, 'Error when validating Intervention: '.$this->commande->error); + throw new RestException(500, 'Error when validating Intervention: '.$this->commande->error); } $this->fichinter->fetchObjectLinked(); @@ -388,10 +387,10 @@ class Interventions extends DolibarrApi $result = $this->fichinter->setStatut(3); if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already closed'); + throw new RestException(304, 'Error nothing done. May be object is already closed'); } if ($result < 0) { - throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error); + throw new RestException(500, 'Error when closing Intervention: '.$this->fichinter->error); } $this->fichinter->fetchObjectLinked(); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 2b06dbbb0c4..66b134fb2e4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3082,54 +3082,56 @@ class CommandeFournisseur extends CommonOrder } return 4; } - }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) - {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) + } elseif (! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) { + //set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) - $close=0; + $close=0; - if( count($diff_array) > 0 ) - {//there are some difference between the two arrays + if( count($diff_array) > 0 ) + { + //there are some difference between the two arrays - //scan the array of results - foreach($diff_array as $key => $value) - {//if the quantity delivered is greater or equal to wish quantity - if($qtydelivered[$key] >= $qtywished[$key] ) - { - $close++; - } - } - } + //scan the array of results + foreach($diff_array as $key => $value) + { + //if the quantity delivered is greater or equal to wish quantity + if($qtydelivered[$key] >= $qtywished[$key] ) + { + $close++; + } + } + } - if($close == count($diff_array)) - {//all the products are received equal or more than the wished quantity - if ($closeopenorder) - { - $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { - return -1; - } - return 5; - } - else - { - //Diff => received partially - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { - return -1; - } - return 4; - } - } - else - {//all the products are not received - $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($ret<0) { - return -1; - } - return 4; - } - } + if($close == count($diff_array)) { + //all the products are received equal or more than the wished quantity + if ($closeopenorder) { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 5; + } + else + { + //Diff => received partially + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + } + else + { + //all the products are not received + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + } else { //Diff => received partially @@ -3145,7 +3147,7 @@ class CommandeFournisseur extends CommonOrder } return 0; } - + /** * Load array this->receptions of lines of shipments with nb of products sent for each order line * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order @@ -3169,7 +3171,7 @@ class CommandeFournisseur extends CommonOrder if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut; $sql.= ' GROUP BY cd.rowid, cd.fk_product'; - + dol_syslog(get_class($this)."::loadReceptions", LOG_DEBUG); $result = $this->db->query($sql); @@ -3184,7 +3186,7 @@ class CommandeFournisseur extends CommonOrder $i++; } $this->db->free(); - + return $num; } else @@ -3319,7 +3321,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->total_ttc = $objp->total_ttc; $this->product_type = $objp->product_type; $this->special_code = $objp->special_code; - + $this->ref = $objp->product_ref; $this->product_ref = $objp->product_ref; $this->product_libelle = $objp->product_libelle; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 0e1ad52d46c..a0a42183b01 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -312,7 +312,7 @@ class CommandeFournisseurDispatch extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error="Error ".$this->db->lasterror(); return -1; } } @@ -391,7 +391,7 @@ class CommandeFournisseurDispatch extends CommonObject $result=$this->call_trigger('LINERECEPTION_UPDATE',$user); if ($result < 0) $error++; //// End call triggers - } + } } // Commit or rollback diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1f8b7b3ba8b..eb48d8e7821 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3218,4 +3218,4 @@ class SupplierInvoiceLine extends CommonObjectLine return -2; } } - } +} diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 04835089809..48ece92479b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2224,227 +2224,227 @@ elseif (! empty($object->id)) dol_fiche_end(); - /** - * Boutons actions - */ + /** + * Boutons actions + */ - if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') + if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete') + { + print '
'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { - print '
'; + $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) + // Validate + if ($object->statut == 0 && $num > 0) { - $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. - - // Validate - if ($object->statut == 0 && $num > 0) + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_order_advance->validate))) - { - $tmpbuttonlabel=$langs->trans('Validate'); - if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + $tmpbuttonlabel=$langs->trans('Validate'); + if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); - print ''; - print $tmpbuttonlabel; - print ''; - } + print ''; + print $tmpbuttonlabel; + print ''; } - // Create event - /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. - { - print ''; - }*/ + } + // Create event + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print ''; + }*/ - // Modify - if ($object->statut == 1) + // Modify + if ($object->statut == 1) + { + if ($user->rights->fournisseur->commande->commander) { - if ($user->rights->fournisseur->commande->commander) - { - print ''.$langs->trans("Modify").''; - } - } - - // Approve - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->approuver) - { - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id)) - { - print ''.$langs->trans("ApproveOrder").''; - } - else - { - print ''.$langs->trans("ApproveOrder").''; - } - } - else - { - print ''.$langs->trans("ApproveOrder").''; - } - } - - // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) - { - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->approve2) - { - if (! empty($object->user_approve_id2)) - { - print ''.$langs->trans("Approve2Order").''; - } - else - { - print ''.$langs->trans("Approve2Order").''; - } - } - else - { - print ''.$langs->trans("Approve2Order").''; - } - } - } - - // Refuse - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2) - { - print ''.$langs->trans("RefuseOrder").''; - } - else - { - print ''.$langs->trans("RefuseOrder").''; - } - } - - // Send - if (in_array($object->statut, array(2, 3, 4, 5))) - { - if ($user->rights->fournisseur->commande->commander) - { - print ''.$langs->trans('SendMail').''; - } - } - - // Reopen - if (in_array($object->statut, array(2))) - { - $buttonshown=0; - if (! $buttonshown && $user->rights->fournisseur->commande->approuver) - { - if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) - || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) - { - print ''.$langs->trans("Disapprove").''; - $buttonshown++; - } - } - if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) - { - if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) - || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) - { - print ''.$langs->trans("Disapprove").''; - } - } - } - if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) - { - if ($user->rights->fournisseur->commande->commander) - { - print ''.$langs->trans("ReOpen").''; - } - } - - // Ship - - if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) - { - if (in_array($object->statut, array(3,4,5))) { - if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) { - print ''; - } else { - print ''; - } - } - } - - if ($object->statut == 2) - { - if ($user->rights->fournisseur->commande->commander) - { - print ''; - } - else - { - print ''; - } - } - - // Create bill - if (! empty($conf->facture->enabled)) - { - if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled - { - if ($user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans("CreateBill").''; - } - } - } - - // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) - if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) // statut 2 means approved - { - if (empty($conf->facture->enabled)) - { - print ''.$langs->trans("ClassifyBilled").''; - } - elseif (!empty($object->linkedObjectsIds['invoice_supplier'])) - { - if ($user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans("ClassifyBilled").''; - } - } - } - - // Create a remote order using WebService only if module is activated - if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted - { - print ''.$langs->trans('CreateRemoteOrder').''; - } - - // Clone - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("ToClone").''; - } - - // Cancel - if ($object->statut == 2) - { - if ($user->rights->fournisseur->commande->commander) - { - print ''.$langs->trans("CancelOrder").''; - } - } - - // Delete - if ($user->rights->fournisseur->commande->supprimer) - { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Modify").''; } } - print "
"; + // Approve + if ($object->statut == 1) + { + if ($user->rights->fournisseur->commande->approuver) + { + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id)) + { + print ''.$langs->trans("ApproveOrder").''; + } + else + { + print ''.$langs->trans("ApproveOrder").''; + } + } + else + { + print ''.$langs->trans("ApproveOrder").''; + } + } + + // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + { + if ($object->statut == 1) + { + if ($user->rights->fournisseur->commande->approve2) + { + if (! empty($object->user_approve_id2)) + { + print ''.$langs->trans("Approve2Order").''; + } + else + { + print ''.$langs->trans("Approve2Order").''; + } + } + else + { + print ''.$langs->trans("Approve2Order").''; + } + } + } + + // Refuse + if ($object->statut == 1) + { + if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2) + { + print ''.$langs->trans("RefuseOrder").''; + } + else + { + print ''.$langs->trans("RefuseOrder").''; + } + } + + // Send + if (in_array($object->statut, array(2, 3, 4, 5))) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans('SendMail').''; + } + } + + // Reopen + if (in_array($object->statut, array(2))) + { + $buttonshown=0; + if (! $buttonshown && $user->rights->fournisseur->commande->approuver) + { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) + || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) + { + print ''.$langs->trans("Disapprove").''; + $buttonshown++; + } + } + if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) + || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) + { + print ''.$langs->trans("Disapprove").''; + } + } + } + if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("ReOpen").''; + } + } + + // Ship + + if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) + { + if (in_array($object->statut, array(3,4,5))) { + if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) { + print ''; + } else { + print ''; + } + } + } + + if ($object->statut == 2) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''; + } + else + { + print ''; + } + } + + // Create bill + if (! empty($conf->facture->enabled)) + { + if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + { + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("CreateBill").''; + } + } + } + + // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) + if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) // statut 2 means approved + { + if (empty($conf->facture->enabled)) + { + print ''.$langs->trans("ClassifyBilled").''; + } + elseif (!empty($object->linkedObjectsIds['invoice_supplier'])) + { + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("ClassifyBilled").''; + } + } + } + + // Create a remote order using WebService only if module is activated + if (! empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted + { + print ''.$langs->trans('CreateRemoteOrder').''; + } + + // Clone + if ($user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("ToClone").''; + } + + // Cancel + if ($object->statut == 2) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("CancelOrder").''; + } + } + + // Delete + if ($user->rights->fournisseur->commande->supprimer) + { + print ''.$langs->trans("Delete").''; + } + } + + print "
"; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a268619c84f..710b463a5b5 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -461,7 +461,7 @@ if ($id > 0 || ! empty($ref)) { if(empty($conf->reception->enabled))print '
'; else print ''; - + print ''; if(empty($conf->reception->enabled))print ''; else print ''; @@ -726,19 +726,19 @@ if ($id > 0 || ! empty($ref)) { // modified by hook if (empty($reshook)) { - if(empty($conf->reception->enabled)){ - print $langs->trans("Comment").' : '; - print 'trans("DispatchSupplierOrder", $object->ref); - // print ' / '.$object->ref_supplier; // Not yet available - print '" class="flat">
'; + if (empty($conf->reception->enabled)){ + print $langs->trans("Comment").' : '; + print 'trans("DispatchSupplierOrder", $object->ref); + // print ' / '.$object->ref_supplier; // Not yet available + print '" class="flat">
'; - print ' '.$checkboxlabel; - } - empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive"); + print ' '.$checkboxlabel; + } + empty($conf->reception->enabled)?$dispatchBt=$langs->trans("DispatchVerb"):$dispatchBt=$langs->trans("Receive"); - print '
'; } @@ -787,7 +787,7 @@ if ($id > 0 || ! empty($ref)) { print ''; if($conf->reception->enabled)print '' . $langs->trans("Reception") . ''; - + print '' . $langs->trans("Product") . ''; print '' . $langs->trans("DateCreation") . ''; print '' . $langs->trans("DateDeliveryPlanned") . ''; @@ -809,19 +809,19 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($resql); print ""; - + if(!empty($conf->reception->enabled) ){ print ''; if (!empty($objp->fk_reception)){ - + $reception = new Reception($db); $reception->fetch($objp->fk_reception); print $reception->getNomUrl(1); } - + print ""; } - + print ''; print '' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . ''; print ' - ' . $objp->label; @@ -895,7 +895,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; print ''; - + print "\n"; diff --git a/htdocs/index.php b/htdocs/index.php index 3a6802abbf8..b3bdd4610c0 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -552,8 +552,8 @@ if ($showweather) $nbworkboardempty=0; if (! empty($valid_dashboardlines)) { - $boxwork.='
'; - + $boxwork.='
'; + foreach($valid_dashboardlines as $board) { if (empty($board->nbtodo)) $nbworkboardempty++; @@ -567,9 +567,9 @@ if (! empty($valid_dashboardlines)) $boxwork .= ''.$board->img.' '.$board->label.'
'; $boxwork .= ''.$board->nbtodo.''; if ($board->total > 0 && ! empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) - { - $boxwork .= ' / '.price($board->total) .''; - } + { + $boxwork .= ' / '.price($board->total) .''; + } $boxwork .= '
'; if ($board->nbtodolate > 0) { @@ -593,7 +593,7 @@ if (! empty($valid_dashboardlines)) $boxwork .='
'; $boxwork .='
'; $boxwork .='
'; - + $boxwork .='
'; $boxwork .=''; } diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 145992c0902..7c023d90aa9 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -312,19 +312,19 @@ else } else { - require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; + require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; - // If password is encoded, we decode it - if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) - { - require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; - if (preg_match('/crypted:/i',$dolibarr_main_db_pass)) - { - $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted - $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); - } - else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); - } + // If password is encoded, we decode it + if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) + { + require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; + if (preg_match('/crypted:/i',$dolibarr_main_db_pass)) + { + $dolibarr_main_db_encrypted_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass); // We need to set this as it is used to know the password was initially crypted + $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } + else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass); + } // $conf already created in inc.php $conf->db->type = $dolibarr_main_db_type; @@ -333,12 +333,12 @@ else $conf->db->name = $dolibarr_main_db_name; $conf->db->user = $dolibarr_main_db_user; $conf->db->pass = $dolibarr_main_db_pass; - $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); + $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port); if ($db->connected && $db->database_selected) { $ok=true; } - } + } } } @@ -569,7 +569,7 @@ else print ''."\n"; print ''; } - } + } } print ' + '; + } + print ''; + } + if ($page > 0) + { + print ''; + } + if ($betweenarrows) + { + print $betweenarrows; + } + if ($nextpage > 0) + { + print ''; + } + if ($afterarrows) + { + print '
  • '; + print $afterarrows; + print '
  • '; + } + print ''."\n"; +} + + +/** + * Return a string with VAT rate label formated for view output + * Used into pdf and HTML pages + * + * @param string $rate Rate value to format ('19.6', '19,6', '19.6%', '19,6%', '19.6 (CODEX)', ...) + * @param boolean $addpercent Add a percent % sign in output + * @param int $info_bits Miscellaneous information on vat (0=Default, 1=French NPR vat) + * @param int $usestarfornpr -1=Never show, 0 or 1=Use '*' for NPR vat rates + * @return string String with formated amounts ('19,6' or '19,6%' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)') + */ +function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0) +{ + $morelabel=''; + + if (preg_match('/%/', $rate)) + { + $rate=str_replace('%', '', $rate); + $addpercent=true; + } + if (preg_match('/\((.*)\)/', $rate, $reg)) + { + $morelabel=' ('.$reg[1].')'; + $rate=preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate); + } + if (preg_match('/\*/', $rate)) + { + $rate=str_replace('*', '', $rate); + $info_bits |= 1; + } + + // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() + if (! preg_match('/\//', $rate)) $ret=price($rate, 0, '', 0, 0).($addpercent?'%':''); + else + { + // TODO Split on / and output with a price2num to have clean numbers without ton of 000. + $ret=$rate.($addpercent?'%':''); + } + if (($info_bits & 1) && $usestarfornpr >= 0) $ret.=' *'; + $ret.=$morelabel; + return $ret; +} + + +/** + * Function to format a value into an amount for visual output + * Function used into PDF and HTML pages + * + * @param float $amount Amount to format + * @param integer $form Type of format, HTML or not (not by default) + * @param Translate $outlangs Object langs for output + * @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless. + * @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT) + * @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force) + * @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency) + * @return string Chaine avec montant formate + * + * @see price2num() Revert function of price + */ +function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code = '') +{ + global $langs,$conf; + + // Clean parameters + if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' + $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) + if ($rounding < 0) $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); + $nbdecimal=$rounding; + + // Output separators by default (french) + $dec=','; $thousand=' '; + + // If $outlangs not forced, we use use language + if (! is_object($outlangs)) $outlangs=$langs; + + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->transnoentitiesnoconv("SeparatorDecimal"); + if ($outlangs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->transnoentitiesnoconv("SeparatorThousand"); + if ($thousand == 'None') $thousand=''; + elseif ($thousand == 'Space') $thousand=' '; + //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
    "; + + //print "amount=".$amount."-"; + $amount = str_replace(',', '.', $amount); // should be useless + //print $amount."-"; + $datas = explode('.', $amount); + $decpart = isset($datas[1])?$datas[1]:''; + $decpart = preg_replace('/0+$/i', '', $decpart); // Supprime les 0 de fin de partie decimale + //print "decpart=".$decpart."
    "; + $end=''; + + // We increase nbdecimal if there is more decimal than asked (to not loose information) + if (dol_strlen($decpart) > $nbdecimal) $nbdecimal=dol_strlen($decpart); + // Si on depasse max + if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) + { + $nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN; + if (preg_match('/\.\.\./i', $conf->global->MAIN_MAX_DECIMALS_SHOWN)) + { + // Si un affichage est tronque, on montre des ... + $end='...'; + } + } + + // If force rounding + if ($forcerounding >= 0) $nbdecimal = $forcerounding; + + // Format number + $output=number_format($amount, $nbdecimal, $dec, $thousand); + if ($form) + { + $output=preg_replace('/\s/', ' ', $output); + $output=preg_replace('/\'/', ''', $output); + } + // Add symbol of currency if requested + $cursymbolbefore=$cursymbolafter=''; + if ($currency_code) + { + if ($currency_code == 'auto') $currency_code=$conf->currency; + + $listofcurrenciesbefore=array('USD','GBP','AUD','MXN','PEN','CNY'); + $listoflanguagesbefore=array('nl_NL'); + if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore)) + { + $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); + } + else + { + $tmpcur=$outlangs->getCurrencySymbol($currency_code); + $cursymbolafter.=($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur); + } + } + $output=$cursymbolbefore.$output.$end.($cursymbolafter?' ':'').$cursymbolafter; + + return $output; +} + +/** + * Function that return a number with universal decimal format (decimal separator is '.') from an amount typed by a user. + * Function to use on each input amount before any numeric test or database insert + * + * @param float $amount Amount to convert/clean + * @param string $rounding ''=No rounding + * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) + * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) + * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) + * Numeric = Nb of digits for rounding + * @param int $alreadysqlnb Put 1 if you know that content is already universal format number + * @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''. + * + * @see price Opposite function of price2num + */ +function price2num($amount, $rounding = '', $alreadysqlnb = 0) +{ + global $langs,$conf; + + // Round PHP function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56' + // Numbers must be '1234.56' + // Decimal delimiter for PHP and database SQL requests must be '.' + $dec=','; $thousand=' '; + if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); + if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); + if ($thousand == 'None') $thousand=''; + elseif ($thousand == 'Space') $thousand=' '; + //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
    "; + + // Convert value to universal number format (no thousand separator, '.' as decimal separator) + if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format + { + //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
    '; + + // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number + // to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup. + if (is_numeric($amount)) + { + // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 + $temps=sprintf("%0.10F", $amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 + $temps=preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1 + $nbofdec=max(0, dol_strlen($temps)-2); // -2 to remove "0." + $amount=number_format($amount, $nbofdec, $dec, $thousand); + } + //print "QQ".$amount.'
    '; + + // Now make replace (the main goal of function) + if ($thousand != ',' && $thousand != '.') $amount=str_replace(',', '.', $amount); // To accept 2 notations for french users + $amount=str_replace(' ', '', $amount); // To avoid spaces + $amount=str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . + $amount=str_replace($dec, '.', $amount); + } + + // Now, make a rounding if required + if ($rounding) + { + $nbofdectoround=''; + if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; + elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; + elseif ($rounding == 'MS') $nbofdectoround=empty($conf->global->MAIN_MAX_DECIMALS_STOCK)?5:$conf->global->MAIN_MAX_DECIMALS_STOCK; + elseif (is_numeric($rounding)) $nbofdectoround=$rounding; + //print "RR".$amount.' - '.$nbofdectoround.'
    '; + if (dol_strlen($nbofdectoround)) $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. + else return 'ErrorBadParameterProvidedToFunction'; + //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'
    '; + + // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number + // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. + if (is_numeric($amount)) + { + // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 + $temps=sprintf("%0.10F", $amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 + $temps=preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1 + $nbofdec=max(0, dol_strlen($temps)-2); // -2 to remove "0." + $amount=number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand + } + //print "TT".$amount.'
    '; + + // Always make replace because each math function (like round) replace + // with local values and we want a number that has a SQL string format x.y + if ($thousand != ',' && $thousand != '.') $amount=str_replace(',', '.', $amount); // To accept 2 notations for french users + $amount=str_replace(' ', '', $amount); // To avoid spaces + $amount=str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . + $amount=str_replace($dec, '.', $amount); + } + + return $amount; +} + + +/** + * Output a dimension with best unit + * + * @param float $dimension Dimension + * @param int $unit Unit of dimension (Example: 0=kg, -3=g, 98=ounce, 99=pound, ...) + * @param string $type 'weight', 'volume', ... + * @param Translate $outputlangs Translate language object + * @param int $round -1 = non rounding, x = number of decimal + * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT) + * @return string String to show dimensions + */ +function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no') +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; + + if (($forceunitoutput == 'no' && $dimension < 1/10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) + { + $dimension = $dimension * 1000000; + $unit = $unit - 6; + } + elseif (($forceunitoutput == 'no' && $dimension < 1/10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) + { + $dimension = $dimension * 1000; + $unit = $unit - 3; + } + elseif (($forceunitoutput == 'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) + { + $dimension = $dimension / 1000000; + $unit = $unit + 6; + } + elseif (($forceunitoutput == 'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) + { + $dimension = $dimension / 1000; + $unit = $unit + 3; + } + // Special case when we want output unit into pound or ounce + /* TODO + if ($unit < 90 && $type == 'weight' && is_numeric($forceunitoutput) && (($forceunitoutput == 98) || ($forceunitoutput == 99)) + { + $dimension = // convert dimension from standard unit into ounce or pound + $unit = $forceunitoutput; + } + if ($unit > 90 && $type == 'weight' && is_numeric($forceunitoutput) && $forceunitoutput < 90) + { + $dimension = // convert dimension from standard unit into ounce or pound + $unit = $forceunitoutput; + }*/ + + $ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type); + + return $ret; +} + + +/** + * Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller + * Note: This function applies same rules than get_default_tva + * + * @param float $vatrate Vat rate. Can be '8.5' or '8.5 (VATCODEX)' for example + * @param int $local Local tax to search and return (1 or 2 return only tax rate 1 or tax rate 2) + * @param Societe $thirdparty_buyer Object of buying third party + * @param Societe $thirdparty_seller Object of selling third party ($mysoc if not defined) + * @param int $vatnpr If vat rate is NPR or not + * @return mixed 0 if not found, localtax rate if found + * @see get_default_tva + */ +function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_seller = "", $vatnpr = 0) +{ + global $db, $conf, $mysoc; + + if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) $thirdparty_seller=$mysoc; + + dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')."/country_code=".(is_object($thirdparty_buyer)?$thirdparty_buyer->country_code:'')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); + + $vatratecleaned = $vatrate; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = trim($reg[1]); + $vatratecode = $reg[2]; + } + + /*if ($thirdparty_buyer->country_code != $thirdparty_seller->country_code) + { + return 0; + }*/ + + // Some test to guess with no need to make database access + if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax + { + if ($local == 1) + { + if (! $mysoc->localtax1_assuj || (string) $vatratecleaned == "0") return 0; + if ($thirdparty_seller->id == $mysoc->id) + { + if (! $thirdparty_buyer->localtax1_assuj) return 0; + } + else + { + if (! $thirdparty_seller->localtax1_assuj) return 0; + } + } + + if ($local == 2) + { + //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; + if (! $mysoc->localtax2_assuj) return 0; // If main vat is 0, IRPF may be different than 0. + if ($thirdparty_seller->id == $mysoc->id) + { + if (! $thirdparty_buyer->localtax2_assuj) return 0; + } + else + { + if (! $thirdparty_seller->localtax2_assuj) return 0; + } + } + } + else + { + if ($local == 1 && ! $thirdparty_seller->localtax1_assuj) return 0; + if ($local == 2 && ! $thirdparty_seller->localtax2_assuj) return 0; + } + + // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. + if (in_array($mysoc->country_code, array('ES'))) + { + $conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1; + } + + // Search local taxes + if (! empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY)) + { + if ($local==1) + { + if ($thirdparty_seller != $mysoc) + { + if (!isOnlyOneLocalTax($local)) // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate + { + return $thirdparty_seller->localtax1_value; + } + } + else // i am the seller + { + if (!isOnlyOneLocalTax($local)) // TODO If seller is me, why not always returning this, even if there is only one locatax vat. + { + return $conf->global->MAIN_INFO_VALUE_LOCALTAX1; + } + } + } + if ($local==2) + { + if ($thirdparty_seller != $mysoc) + { + if (!isOnlyOneLocalTax($local)) // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate + // TODO We should also return value defined on thirdparty only if defined + { + return $thirdparty_seller->localtax2_value; + } + } + else // i am the seller + { + if (in_array($mysoc->country_code, array('ES'))) + { + return $thirdparty_buyer->localtax2_value; + } + else + { + return $conf->global->MAIN_INFO_VALUE_LOCALTAX2; + } + } + } + } + + // By default, search value of local tax on line of common tax + $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'"; + $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority + else $sql.= " AND t.recuperableonly ='".$vatnpr."'"; + dol_syslog("get_localtax", LOG_DEBUG); + $resql=$db->query($sql); + + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($local==1) return $obj->localtax1; + elseif ($local==2) return $obj->localtax2; + } + + return 0; +} + + +/** + * Return true if LocalTax (1 or 2) is unique. + * Example: If localtax1 is 5 on line with highest common vat rate, return true + * Example: If localtax1 is 5:8:15 on line with highest common vat rate, return false + * + * @param int $local Local tax to test (1 or 2) + * @return boolean True if LocalTax have multiple values, False if not + */ +function isOnlyOneLocalTax($local) +{ + $tax=get_localtax_by_third($local); + + $valors=explode(":", $tax); + + if (count($valors)>1) + { + return false; + } + else + { + return true; + } +} + +/** + * Get values of localtaxes (1 or 2) for company country for the common vat with the highest value + * + * @param int $local LocalTax to get + * @return number Values of localtax + */ +function get_localtax_by_third($local) +{ + global $db, $mysoc; + $sql ="SELECT t.localtax1, t.localtax2 "; + $sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays"; + $sql.=" WHERE c.code = '".$mysoc->country_code."' AND t.active = 1 AND t.taux=("; + $sql.=" SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays"; + $sql.=" WHERE c.code = '".$mysoc->country_code."' AND tt.active = 1"; + $sql.=" )"; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($local==1) return $obj->localtax1; + elseif ($local==2) return $obj->localtax2; + } + + return 0; +} + + +/** + * Get vat main information from Id. + * You can call getLocalTaxesFromRate after to get other fields. + * + * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is id into table (use this if you can) + * @return array array('rowid'=> , 'code'=> ...) + * @see getLocalTaxesFromRate + */ +function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1) +{ + global $db, $mysoc; + + dol_syslog("getTaxesFromId vat id or rate = ".$vatrate); + + // Search local taxes + $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; + else + { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; + /*if ($mysoc->country_code == 'ES') $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // vat in spain use the buyer country ?? + else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";*/ + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; + $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; + } + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); + else return array(); + } + else dol_print_error($db); + + return array(); +} + +/** + * Get type and rate of localtaxes for a particular vat rate/country of a thirdparty. + * This does not take into account the seller setup if subject to vat or not, only country. + * TODO + * This function is ALSO called to retrieve type for building PDF. Such call of function must be removed. + * Instead this function must be called when adding a line to get the array of localtax and type, and then + * provide it to the function calcul_price_total. + * + * @param int|string $vatrate VAT ID or Rate+Code. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123. + * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) + * @param Societe $buyer Company object + * @param Societe $seller Company object + * @param int $firstparamisid 1 if first param is ID into table instead of Rate+code (use this if you can) + * @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type2, rate localtax2, accountancycodecust, accountancycodesupp) + * @see getTaxesFromId + */ +function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid = 0) +{ + global $db, $mysoc; + + dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); + + // Search local taxes + $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; + if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; + else + { + $vatratecleaned = $vatrate; + $vatratecode = ''; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "x.x (yy)" + { + $vatratecleaned = $reg[1]; + $vatratecode = $reg[2]; + } + + $sql.=", ".MAIN_DB_PREFIX."c_country as c"; + if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? + else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; + $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; + if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; + } + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($local == 1) + { + return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); + } + elseif ($local == 2) + { + return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell, $obj->accountancy_code_buy); + } + else + { + return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); + } + } + + return 0; +} + +/** + * Return vat rate of a product in a particular selling country or default country vat if product is unknown + * Function called by get_default_tva + * + * @param int $idprod Id of product or 0 if not a predefined product + * @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...) + * @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice) + * @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)' + * @see get_product_localtax_for_country + */ +function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice = 0) +{ + global $db,$conf,$mysoc; + + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + + $ret=0; + $found=0; + + if ($idprod > 0) + { + // Load product + $product=new Product($db); + $result=$product->fetch($idprod); + + if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours + { + if ($idprodfournprice > 0) // We want vat for product for a "supplier" object + { + $product->get_buyprice($idprodfournprice, 0, 0, 0); + $ret=$product->vatrate_supplier; + if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')'; + } + else + { + $ret=$product->tva_tx; // Default vat of product we defined + if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')'; + } + $found=1; + } + else + { + // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. + // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on + } + } + + if (! $found) + { + if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) + { + // If vat of product for the country not found or not defined, we return the first higher vat of country. + $sql = "SELECT t.taux as vat_rate, t.code as default_vat_code"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'"; + $sql.= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC"; + $sql.= $db->plimit(1); + + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + $ret=$obj->vat_rate; + if ($obj->default_vat_code) $ret.=' ('.$obj->default_vat_code.')'; + } + $db->free($sql); + } + else dol_print_error($db); + } + else $ret=$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails + } + + dol_syslog("get_product_vat_for_country: ret=".$ret); + return $ret; +} + +/** + * Return localtax vat rate of a product in a particular selling country or default country vat if product is unknown + * + * @param int $idprod Id of product + * @param int $local 1 for localtax1, 2 for localtax 2 + * @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...) + * @return int <0 if KO, Vat rate if OK + * @see get_product_vat_for_country + */ +function get_product_localtax_for_country($idprod, $local, $thirdparty_seller) +{ + global $db,$mysoc; + + if (! class_exists('Product')) { + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + } + + $ret=0; + $found=0; + + if ($idprod > 0) + { + // Load product + $product=new Product($db); + $result=$product->fetch($idprod); + + if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours + { + /* Not defined yet, so we don't use this + if ($local==1) $ret=$product->localtax1_tx; + elseif ($local==2) $ret=$product->localtax2_tx; + $found=1; + */ + } + else + { + // TODO Read default product vat according to countrycode and product + } + } + + if (! $found) + { + // If vat of product for the country not found or not defined, we return higher vat of country. + $sql = "SELECT taux as vat_rate, localtax1, localtax2"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'"; + $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; + $sql.= $db->plimit(1); + + $resql=$db->query($sql); + if ($resql) + { + $obj=$db->fetch_object($resql); + if ($obj) + { + if ($local==1) $ret=$obj->localtax1; + elseif ($local==2) $ret=$obj->localtax2; + } + } + else dol_print_error($db); + } + + dol_syslog("get_product_localtax_for_country: ret=".$ret); + return $ret; +} + +/** + * Function that return vat rate of a product line (according to seller, buyer and product vat rate) + * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par defaut=TVA du produit vendu. Fin de regle + * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par defaut=0. Fin de regle + * Sinon TVA proposee par defaut=0. Fin de regle. + * + * @param Societe $thirdparty_seller Objet societe vendeuse + * @param Societe $thirdparty_buyer Objet societe acheteuse + * @param int $idprod Id product + * @param int $idprodfournprice Id product_fournisseur_price (for supplier order/invoice) + * @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)', -1 if we can't guess it + * @see get_default_npr, get_default_localtax + */ +function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0) +{ + global $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + + // Note: possible values for tva_assuj are 0/1 or franchise/reel + $seller_use_vat=((is_numeric($thirdparty_seller->tva_assuj) && ! $thirdparty_seller->tva_assuj) || (! is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj=='franchise'))?0:1; + + $seller_country_code = $thirdparty_seller->country_code; + $seller_in_cee = isInEEC($thirdparty_seller); + + $buyer_country_code = $thirdparty_buyer->country_code; + $buyer_in_cee = isInEEC($thirdparty_buyer); + + dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)?$conf->global->SERVICES_ARE_ECOMMERCE_200238EC:'')); + + // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm) + // we use the buyer VAT. + if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) + { + if ($seller_in_cee && $buyer_in_cee && ! $thirdparty_buyer->isACompany()) + { + //print 'VATRULE 0'; + return get_product_vat_for_country($idprod, $thirdparty_buyer, $idprodfournprice); + } + } + + // If seller does not use VAT + if (! $seller_use_vat) + { + //print 'VATRULE 1'; + return 0; + } + + // Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant. + + // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. + if (($seller_country_code == $buyer_country_code) + || (in_array($seller_country_code, array('FR,MC')) && in_array($buyer_country_code, array('FR','MC')))) // Warning ->country_code not always defined + { + //print 'VATRULE 2'; + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } + + // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + // Not supported + + // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise) alors TVA par defaut=0. Fin de regle + // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + if (($seller_in_cee && $buyer_in_cee)) + { + $isacompany=$thirdparty_buyer->isACompany(); + if ($isacompany) + { + //print 'VATRULE 3'; + return 0; + } + else + { + //print 'VATRULE 4'; + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } + } + + // Si (vendeur en France et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + if (! empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany()) { + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } + + // Sinon la TVA proposee par defaut=0. Fin de regle. + // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe + //print 'VATRULE 5'; + return 0; +} + + +/** + * Fonction qui renvoie si tva doit etre tva percue recuperable + * + * @param Societe $thirdparty_seller Thirdparty seller + * @param Societe $thirdparty_buyer Thirdparty buyer + * @param int $idprod Id product + * @param int $idprodfournprice Id supplier price for product + * @return float 0 or 1 + * @see get_default_tva, get_default_localtax + */ +function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0) +{ + global $db; + + if ($idprodfournprice > 0) + { + if (! class_exists('ProductFournisseur')) + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; + $prodprice = new ProductFournisseur($db); + $prodprice->fetch_product_fournisseur_price($idprodfournprice); + return $prodprice->fourn_tva_npr; + } + elseif ($idprod > 0) + { + if (! class_exists('Product')) + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + $prod = new Product($db); + $prod->fetch($idprod); + return $prod->tva_npr; + } + + return 0; +} + +/** + * Function that return localtax of a product line (according to seller, buyer and product vat rate) + * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. + * Sinon TVA proposee par defaut=0. Fin de regle. + * + * @param Societe $thirdparty_seller Thirdparty seller + * @param Societe $thirdparty_buyer Thirdparty buyer + * @param int $local Localtax to process (1 or 2) + * @param int $idprod Id product + * @return integer localtax, -1 si ne peut etre determine + * @see get_default_tva, get_default_npr + */ +function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod = 0) +{ + global $mysoc; + + if (!is_object($thirdparty_seller)) return -1; + if (!is_object($thirdparty_buyer)) return -1; + + if ($local==1) // Localtax 1 + { + if ($mysoc->country_code == 'ES') + { + if (is_numeric($thirdparty_buyer->localtax1_assuj) && ! $thirdparty_buyer->localtax1_assuj) return 0; + } + else + { + // Si vendeur non assujeti a Localtax1, localtax1 par default=0 + if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) return 0; + if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') return 0; + } + } + elseif ($local==2) //I Localtax 2 + { + // Si vendeur non assujeti a Localtax2, localtax2 par default=0 + if (is_numeric($thirdparty_seller->localtax2_assuj) && ! $thirdparty_seller->localtax2_assuj) return 0; + if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') return 0; + } + + if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) + { + return get_product_localtax_for_country($idprod, $local, $thirdparty_seller); + } + + return 0; +} + +/** + * Return yes or no in current language + * + * @param string $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false') + * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No + * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color. + * @return string HTML string + */ +function yn($yesno, $case = 1, $color = 0) +{ + global $langs; + $result='unknown'; $classname=''; + if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0 + { + $result=$langs->trans('yes'); + if ($case == 1 || $case == 3) $result=$langs->trans("Yes"); + if ($case == 2) $result=''; + if ($case == 3) $result=' '.$result; + + $classname='ok'; + } + elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') + { + $result=$langs->trans("no"); + if ($case == 1 || $case == 3) $result=$langs->trans("No"); + if ($case == 2) $result=''; + if ($case == 3) $result=' '.$result; + + if ($color == 2) $classname='ok'; + else $classname='error'; + } + if ($color) return ''.$result.''; + return $result; +} + + +/** + * Return a path to have a the directory according to object where files are stored. + * New usage: $conf->module->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart) + * or: $conf->module->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, $modulepart) if multidir_output not defined. + * Example our with new usage: $object is invoice -> 'INYYMM-ABCD' + * Example our with old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/" + * + * @param string $num Id of object (deprecated, $object will be used in future) + * @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future) + * @param int $alpha 0=Keep number only to forge path, 1=Use alpha part afer the - (By default, use 0). (deprecated, global option will be used in future) + * @param int $withoutslash 0=With slash at end (except if '/', we return ''), 1=without slash at end + * @param Object $object Object + * @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...') + * @return string Dir to use ending. Example '' or '1/' or '1/2/' + */ +function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) +{ + global $conf; + + $path = ''; + + $arrayforoldpath=array('cheque','user','category','holiday','supplier_invoice','invoice_supplier','mailing','supplier_payment'); + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; + if (! empty($level) && in_array($modulepart, $arrayforoldpath)) + { + // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. + if (empty($alpha)) $num = preg_replace('/([^0-9])/i', '', $num); + else $num = preg_replace('/^.*\-/i', '', $num); + $num = substr("000".$num, -$level); + if ($level == 1) $path = substr($num, 0, 1); + if ($level == 2) $path = substr($num, 1, 1).'/'.substr($num, 0, 1); + if ($level == 3) $path = substr($num, 2, 1).'/'.substr($num, 1, 1).'/'.substr($num, 0, 1); + } + else + { + // TODO + // We will enhance here a common way of forging path for document storage + // Here, object->id, object->ref and modulepart are required. + //var_dump($modulepart); + if (in_array($modulepart, array('thirdparty','contact','member','propal','proposal','commande','order','facture','invoice', + 'supplier_order','supplier_proposal','shipment','contract','expensereport'))) + { + $path=($object->ref?$object->ref:$object->id); + } + } + + if (empty($withoutslash) && ! empty($path)) $path.='/'; + + return $path; +} + +/** + * Creation of a directory (this can create recursive subdir) + * + * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') + * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) + * @param int $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' + * @return int < 0 if KO, 0 = already exists, > 0 if OK + */ +function dol_mkdir($dir, $dataroot = '', $newmask = null) +{ + global $conf; + + dol_syslog("functions.lib::dol_mkdir: dir=".$dir, LOG_INFO); + + $dir_osencoded=dol_osencode($dir); + if (@is_dir($dir_osencoded)) return 0; + + $nberr=0; + $nbcreated=0; + + $ccdir=''; + if (! empty($dataroot)) { + // Remove data root from loop + $dir = str_replace($dataroot.'/', '', $dir); + $ccdir = $dataroot.'/'; + } + + $cdir = explode("/", $dir); + $num=count($cdir); + for ($i = 0; $i < $num; $i++) + { + if ($i > 0) $ccdir .= '/'.$cdir[$i]; + else $ccdir .= $cdir[$i]; + if (preg_match("/^.:$/", $ccdir, $regs)) continue; // Si chemin Windows incomplet, on poursuit par rep suivant + + // Attention, le is_dir() peut echouer bien que le rep existe. + // (ex selon config de open_basedir) + if ($ccdir) + { + $ccdir_osencoded=dol_osencode($ccdir); + if (! @is_dir($ccdir_osencoded)) + { + dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG); + + umask(0); + $dirmaskdec=octdec($newmask); + if (empty($newmask)) { + $dirmaskdec = empty( $conf->global->MAIN_UMASK ) ? octdec( '0755' ) : octdec( $conf->global->MAIN_UMASK ); + } + $dirmaskdec |= octdec('0111'); // Set x bit required for directories + if (! @mkdir($ccdir_osencoded, $dirmaskdec)) + { + // Si le is_dir a renvoye une fausse info, alors on passe ici. + dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING); + $nberr++; + } + else + { + dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created", LOG_DEBUG); + $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore + $nbcreated++; + } + } + else + { + $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignores + } + } + } + return ($nberr ? -$nberr : $nbcreated); +} + + +/** + * Return picto saying a field is required + * + * @return string Chaine avec picto obligatoire + */ +function picto_required() +{ + return '*'; +} + + +/** + * Clean a string from all HTML tags and entities. + * This function differs from strip_tags because: + * -
    are replaced with \n if removelinefeed=0 or 1 + * - if entities are found, they are decoded BEFORE the strip + * - you can decide to convert line feed into a space + * + * @param string $stringtoclean String to clean + * @param integer $removelinefeed 1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with \n, 2=Ending new lines are removed but others are kept with a same number of \n than nb of
    when there is both "...
    \n..." + * @param string $pagecodeto Encoding of input/output string + * @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag) + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags + */ +function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) +{ + if ($removelinefeed == 2) $stringtoclean = preg_replace('/]*>\n+/ims', '
    ', $stringtoclean); + $temp = preg_replace('/]*>/i', "\n", $stringtoclean); + + if ($strip_tags) { + $temp = strip_tags($temp); + } else { + $pattern = "/<[^<>]+>/"; + // Exemple of $temp: 0000-021 + $temp = preg_replace($pattern, "", $temp); // pass 1 + // $temp after pass 1: 0000-021 + $temp = preg_replace($pattern, "", $temp); // pass 2 + // $temp after pass 2: 0000-021 + } + + $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); + + // Supprime aussi les retours + if ($removelinefeed == 1) $temp=str_replace(array("\r\n","\r","\n"), " ", $temp); + + // et les espaces doubles + while (strpos($temp, " ")) + { + $temp = str_replace(" ", " ", $temp); + } + + return trim($temp); +} + +/** + * Clean a string to keep only desirable HTML tags. + * + * @param string $stringtoclean String to clean + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags + */ +function dol_string_onlythesehtmltags($stringtoclean) +{ + $allowed_tags = array( + "html", "head", "meta", "body", "article", "a", "b", "br", "div", "em", "font", "img", "ins", "hr", "i", "li", "link", + "ol", "p", "s", "section", "span", "strong", "title", + "table", "tr", "th", "td", "u", "ul" + ); + + $allowed_tags_string = join("><", $allowed_tags); + $allowed_tags_string = preg_replace('/^>/', '', $allowed_tags_string); + $allowed_tags_string = preg_replace('/<$/', '', $allowed_tags_string); + + $temp = strip_tags($stringtoclean, $allowed_tags_string); + + return $temp; +} + +/** + * Clean a string from some undesirable HTML tags. + * + * @param string $stringtoclean String to clean + * @param array $disallowed_tags Array of tags not allowed + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags + */ +function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array('textarea')) +{ + $temp = $stringtoclean; + foreach($disallowed_tags as $tagtoremove) + { + $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp); + $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp); + } + return $temp; +} + + +/** + * Return first line of text. Cut will depends if content is HTML or not. + * + * @param string $text Input text + * @param int $nboflines Nb of lines to get (default is 1 = first line only) + * @return string Output text + * @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag + */ +function dolGetFirstLineOfText($text, $nboflines = 1) +{ + if ($nboflines == 1) + { + if (dol_textishtml($text)) + { + $firstline=preg_replace('/]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters + $firstline=preg_replace('/]*>.*$/s', '', $firstline); // The s pattern modifier means the . can match newline characters + } + else + { + $firstline=preg_replace('/[\n\r].*/', '', $text); + } + return $firstline.((strlen($firstline) != strlen($text))?'...':''); + } + else + { + $ishtml=0; + if (dol_textishtml($text)) + { + $text=preg_replace('/\n/', '', $text); + $ishtml=1; + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); + } + else + { + $repTable = array("\t" => " ", "\n" => "
    ", "\r" => " ", "\0" => " ", "\x0B" => " "); + } + + $text = strtr($text, $repTable); + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. + $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + $firstline=''; + $i=0; + $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator + while (($i < $nba) && ($i < ($nboflines * 2))) + { + if ($i % 2 == 0) $firstline .= $a[$i]; + elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"
    \n":"\n"); + $i++; + } + unset($a); + return $firstline.(($i < $nba)?'...':''); + } +} + + +/** + * Replace CRLF in string with a HTML BR tag + * + * @param string $stringtoencode String to encode + * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br + * @param bool $forxml false=Use
    , true=Use
    + * @return string String encoded + * @see dol_nboflines, dolGetFirstLineOfText + */ +function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false) +{ + if (!$nl2brmode) { + return nl2br($stringtoencode, $forxml); + } else { + $ret=preg_replace('/(\r\n|\r|\n)/i', ($forxml?'
    ':'
    '), $stringtoencode); + return $ret; + } +} + + +/** + * This function is called to encode a string into a HTML string but differs from htmlentities because + * a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted. + * This permits to encode special chars to entities with no double encoding for already encoded HTML strings. + * This function also remove last EOL or BR if $removelasteolbr=1 (default). + * For PDF usage, you can show text by 2 ways: + * - writeHTMLCell -> param must be encoded into HTML. + * - MultiCell -> param must not be encoded into HTML. + * Because writeHTMLCell convert also \n into
    , if function + * is used to build PDF, nl2brmode must be 1. + * + * @param string $stringtoencode String to encode + * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example) + * @param string $pagecodefrom Pagecode stringtoencode is encoded + * @param int $removelasteolbr 1=Remove last br or lasts \n (default), 0=Do nothing + * @return string String encoded + */ +function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UTF-8', $removelasteolbr = 1) +{ + $newstring=$stringtoencode; + if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not + { + $newstring=preg_replace('//i', '
    ', $newstring); // Replace "
    " by "
    ". It's same and avoid pb with FPDF. + if ($removelasteolbr) $newstring=preg_replace('/
    $/i', '', $newstring); // Remove last
    (remove only last one) + $newstring=strtr($newstring, array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); + $newstring=dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding + $newstring=strtr($newstring, array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); + } + else + { + if ($removelasteolbr) $newstring=preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several) + $newstring=dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode); + } + // Other substitutions that htmlentities does not do + //$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table. // Seems useles with TCPDF. Make bug with UTF8 languages + return $newstring; +} + +/** + * This function is called to decode a HTML string (it decodes entities and br tags) + * + * @param string $stringtodecode String to decode + * @param string $pagecodeto Page code for result + * @return string String decoded + */ +function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8') +{ + $ret=dol_html_entity_decode($stringtodecode, ENT_COMPAT, $pagecodeto); + $ret=preg_replace('/'."\r\n".'/i', "
    ", $ret); + $ret=preg_replace('/'."\r\n".'/i', "\r\n", $ret); + $ret=preg_replace('/'."\n".'/i', "\n", $ret); + $ret=preg_replace('//i', "\n", $ret); + return $ret; +} + +/** + * This function remove all ending \n and br at end + * + * @param string $stringtodecode String to decode + * @return string String decoded + */ +function dol_htmlcleanlastbr($stringtodecode) +{ + $ret=preg_replace('/(
    ||'."\n".'|'."\r".')+$/i', "", $stringtodecode); + return $ret; +} + +/** + * Replace html_entity_decode functions to manage errors + * + * @param string $a Operand a + * @param string $b Operand b (ENT_QUOTES=convert simple and double quotes) + * @param string $c Operand c + * @return string String decoded + */ +function dol_html_entity_decode($a, $b, $c = 'UTF-8') +{ + return html_entity_decode($a, $b, $c); +} + +/** + * Replace htmlentities functions. + * Goal of this function is to be sure to have default values of htmlentities that match what we need. + * + * @param string $string The input string to encode + * @param int $flags Flags (see PHP doc above) + * @param string $encoding Encoding page code + * @param bool $double_encode When double_encode is turned off, PHP will not encode existing html entities + * @return string $ret Encoded string + */ +function dol_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_encode = false) +{ + return htmlentities($string, $flags, $encoding, $double_encode); +} + +/** + * Check if a string is a correct iso string + * If not, it will we considered not HTML encoded even if it is by FPDF. + * Example, if string contains euro symbol that has ascii code 128 + * + * @param string $s String to check + * @return int 0 if bad iso, 1 if good iso + */ +function dol_string_is_good_iso($s) +{ + $len=dol_strlen($s); + $ok=1; + for($scursor=0;$scursor<$len;$scursor++) + { + $ordchar=ord($s{$scursor}); + //print $scursor.'-'.$ordchar.'
    '; + if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; } + if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } + } + return $ok; +} + + +/** + * Return nb of lines of a clear text + * + * @param string $s String to check + * @param int $maxchar Not yet used + * @return int Number of lines + * @see dol_nboflines_bis, dolGetFirstLineOfText + */ +function dol_nboflines($s, $maxchar = 0) +{ + if ($s == '') return 0; + $arraystring=explode("\n", $s); + $nb=count($arraystring); + + return $nb; +} + + +/** + * Return nb of lines of a formated text with \n and
    (WARNING: string must not have mixed \n and br separators) + * + * @param string $text Text + * @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut) + * @param string $charset Give the charset used to encode the $text variable in memory. + * @return int Number of lines + * @see dol_nboflines, dolGetFirstLineOfText + */ +function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') +{ + $repTable = array("\t" => " ", "\n" => "
    ", "\r" => " ", "\0" => " ", "\x0B" => " "); + if (dol_textishtml($text)) $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); + + $text = strtr($text, $repTable); + if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support + else $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. + $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + $nblines = (int) floor((count($a)+1)/2); + // count possible auto line breaks + if($maxlinesize) + { + foreach ($a as $line) + { + if (dol_strlen($line)>$maxlinesize) + { + //$line_dec = html_entity_decode(strip_tags($line)); + $line_dec = html_entity_decode($line); + if(dol_strlen($line_dec)>$maxlinesize) + { + $line_dec=wordwrap($line_dec, $maxlinesize, '\n', true); + $nblines+=substr_count($line_dec, '\n'); + } + } + } + } + + unset($a); + return $nblines; +} + +/** + * Same function than microtime in PHP 5 but compatible with PHP4 + * + * @return float Time (millisecondes) with microsecondes in decimal part + * @deprecated Dolibarr does not support PHP4, you should use native function + * @see microtime() + */ +function dol_microtime_float() +{ + dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); + + return microtime(true); +} + +/** + * Return if a text is a html content + * + * @param string $msg Content to check + * @param int $option 0=Full detection, 1=Fast check + * @return boolean true/false + * @see dol_concatdesc + */ +function dol_textishtml($msg, $option = 0) +{ + if ($option == 1) + { + if (preg_match('//i', $msg)) return true; + elseif (preg_match('//i', $msg)) return true; + elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) return true; + elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) return true; + elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) return true; + elseif (preg_match('/]*src[^<>]*>/i', $msg)) return true; // must accept + elseif (preg_match('/]*href[^<>]*>/i', $msg)) return true; // must accept
    + elseif (preg_match('//i', $msg)) return true; + elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) + elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) + + return false; + } +} + +/** + * Concat 2 descriptions with a new line between them (second operand after first one with appropriate new line separator) + * text1 html + text2 html => text1 + '
    ' + text2 + * text1 html + text2 txt => text1 + '
    ' + dol_nl2br(text2) + * text1 txt + text2 html => dol_nl2br(text1) + '
    ' + text2 + * text1 txt + text2 txt => text1 + '\n' + text2 + * + * @param string $text1 Text 1 + * @param string $text2 Text 2 + * @param bool $forxml false=Use
    instead of \n if html content detected, true=Use
    instead of \n if html content detected + * @param bool $invert invert order of description lines if CONF CHANGE_ORDER_CONCAT_DESCRIPTION is active + * @return string Text 1 + new line + Text2 + * @see dol_textishtml + */ +function dol_concatdesc($text1, $text2, $forxml = false, $invert = false) +{ + if (!empty($invert)) + { + $tmp = $text1; + $text1 = $text2; + $text2 = $tmp; + } + + $ret=''; + $ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1; + $ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"
    \n":"
    \n") : "\n") : ""; + $ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2; + return $ret; +} + + + +/** + * Return array of possible common substitutions. This includes several families like: 'system', 'mycompany', 'object', 'objectamount', 'date', 'user' + * + * @param Translate $outputlangs Output language + * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are trunc and html sanitized (to use for help tooltip) + * @param array $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...) + * @param Object $object Object for keys on object + * @return array Array of substitutions + * @see setSubstitFromObject + */ +function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null) +{ + global $db, $conf, $mysoc, $user, $extrafields; + + $substitutionarray=array(); + + if (empty($exclude) || ! in_array('user', $exclude)) + { + // Add SIGNATURE into substitutionarray first, so, when we will make the substitution, + // this will include signature content first and then replace var found into content of signature + $signature = $user->signature; + $substitutionarray=array_merge($substitutionarray, array( + '__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '') + ) + ); + // For backward compatibility + if ($onlykey != 2) + { + $substitutionarray['__SIGNATURE__'] = (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : ''); + } + + $substitutionarray=array_merge($substitutionarray, array( + '__USER_ID__' => (string) $user->id, + '__USER_LOGIN__' => (string) $user->login, + '__USER_LASTNAME__' => (string) $user->lastname, + '__USER_FIRSTNAME__' => (string) $user->firstname, + '__USER_FULLNAME__' => (string) $user->getFullName($outputlangs), + '__USER_SUPERVISOR_ID__' => (string) ($user->fk_user ? $user->fk_user : '0'), + '__USER_REMOTE_IP__' => (string) getUserRemoteIP() + ) + ); + } + if ((empty($exclude) || ! in_array('mycompany', $exclude)) && is_object($mysoc)) + { + $substitutionarray=array_merge($substitutionarray, array( + '__MYCOMPANY_NAME__' => $mysoc->name, + '__MYCOMPANY_EMAIL__' => $mysoc->email, + '__MYCOMPANY_PROFID1__' => $mysoc->idprof1, + '__MYCOMPANY_PROFID2__' => $mysoc->idprof2, + '__MYCOMPANY_PROFID3__' => $mysoc->idprof3, + '__MYCOMPANY_PROFID4__' => $mysoc->idprof4, + '__MYCOMPANY_PROFID5__' => $mysoc->idprof5, + '__MYCOMPANY_PROFID6__' => $mysoc->idprof6, + '__MYCOMPANY_CAPITAL__' => $mysoc->capital, + '__MYCOMPANY_FULLADDRESS__' => $mysoc->getFullAddress(1, ', '), + '__MYCOMPANY_ADDRESS__' => $mysoc->address, + '__MYCOMPANY_ZIP__' => $mysoc->zip, + '__MYCOMPANY_TOWN__' => $mysoc->town, + '__MYCOMPANY_COUNTRY__' => $mysoc->country, + '__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id, + '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency + )); + } + + if (($onlykey || is_object($object)) && (empty($exclude) || ! in_array('object', $exclude))) + { + if ($onlykey) + { + $substitutionarray['__ID__'] = '__ID__'; + $substitutionarray['__REF__'] = '__REF__'; + $substitutionarray['__REF_CLIENT__'] = '__REF_CLIENT__'; + $substitutionarray['__REF_SUPPLIER__'] = '__REF_SUPPLIER__'; + $substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__'; + + $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; + $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__'; + $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; + + if (! empty($conf->adherent->enabled)) + { + $substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__'; + $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; + $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; + $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + } + $substitutionarray['__PROJECT_ID__'] = '__PROJECT_ID__'; + $substitutionarray['__PROJECT_REF__'] = '__PROJECT_REF__'; + $substitutionarray['__PROJECT_NAME__'] = '__PROJECT_NAME__'; + + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = 'Highest date planned for a service start'; + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = 'Highest date and hour planned for service start'; + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service'; + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service'; + + $substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable'; + $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = 'TextAndUrlToPayOnlineIfApplicable'; + $substitutionarray['__SECUREKEYPAYMENT__'] = 'Security key (if key is not unique per record)'; + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = 'Security key for payment on a member subscription (one key per member)'; + $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order'; + $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice'; + $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service'; + + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = 'Direct download url of a proposal'; + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = 'Direct download url of an order'; + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = 'Direct download url of an invoice'; + + if (! empty($conf->expedition->enabled)) + { + $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; + $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; + } + } + else + { + $substitutionarray['__ID__'] = $object->id; + $substitutionarray['__REF__'] = $object->ref; + $substitutionarray['__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); + $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); + // For backward compatibility + $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); + $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); + + // TODO Remove this + $msgishtml = 0; + + $birthday = dol_print_date($object->birth, 'day'); + + if ($object->id > 0) + { + $substitutionarray['__MEMBER_ID__']=$object->id; + if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); + $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; + $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; + if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); + $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; + $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; + $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; + $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town; + $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country; + $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email; + $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday; + $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo; + $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login; + $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass; + $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone; + $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso; + $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile; + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc'); + $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc'); + } + + if (is_object($object) && $object->element == 'societe') + { + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); + } + elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) + { + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); + } + + if (is_object($object->projet) && $object->projet->id > 0) + { + $substitutionarray['__PROJECT_ID__'] = (is_object($object->projet)?$object->projet->id:''); + $substitutionarray['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); + } + + if (is_object($object) && $object->element == 'shipping') + { + $substitutionarray['__SHIPPINGTRACKNUM__']=$object->tracking_number; + $substitutionarray['__SHIPPINGTRACKNUMURL__']=$object->tracking_url; + } + + if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) + { + if ($object->id > 0) + { + $dateplannedstart=''; + $datenextexpiration=''; + foreach($object->lines as $line) + { + if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue; + if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue; + } + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); + $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); + $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); + } + } + + // Create dynamic tags for __EXTRAFIELD_FIELD__ + if ($object->table_element && $object->id > 0) + { + if (! is_object($extrafields)) $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($object->table_element, true); + + if ($object->fetch_optionals() > 0) + { + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) + { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { + $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; + } + } + } + } + + // Complete substitution array with the url to make online payment + $paymenturl=''; + if (empty($substitutionarray['__REF__'])) + { + $paymenturl=''; + } + else + { + // Set the online payment url link into __ONLINE_PAYMENT_URL__ key + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + $outputlangs->loadLangs(array('paypal','other')); + $typeforonlinepayment='free'; + if (is_object($object) && $object->element == 'commande') $typeforonlinepayment='order'; + if (is_object($object) && $object->element == 'facture') $typeforonlinepayment='invoice'; + if (is_object($object) && $object->element == 'member') $typeforonlinepayment='member'; + $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); + $paymenturl=$url; + } + + if ($object->id > 0) + { + $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):''); + $substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl; + + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; + if (! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; + if (! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') + { + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); + } + else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; + } + } + } + if (empty($exclude) || ! in_array('objectamount', $exclude)) + { + $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : ''; + $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : null) : ''; + + $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; + $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:''; + $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?$object->total_localtax1:''; + if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?$object->total_localtax2:''; + + $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?($object->total_ttc ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?($object->total_ht ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency): ($object->total_tva ? price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency) : null)):''; + if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)? ($object->total_localtax1 ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)? ($object->total_localtax2 ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):''; + + // TODO Add keys for foreign multicurrency + + // For backward compatibility + if ($onlykey != 2) + { + $substitutionarray['__TOTAL_TTC__'] = is_object($object)?$object->total_ttc:''; + $substitutionarray['__TOTAL_HT__'] = is_object($object)?$object->total_ht:''; + $substitutionarray['__TOTAL_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; + } + } + + //var_dump($substitutionarray['__AMOUNT_FORMATED__']); + if (empty($exclude) || ! in_array('date', $exclude)) + { + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + + $tmp=dol_getdate(dol_now(), true); + $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); + $tmp3=dol_get_prev_month($tmp['mon'], $tmp['year']); + $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); + $tmp5=dol_get_next_month($tmp['mon'], $tmp['year']); + + $substitutionarray=array_merge($substitutionarray, array( + '__DAY__' => (string) $tmp['mday'], + '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday + '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon + '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M + '__MONTH__' => (string) $tmp['mon'], + '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])), + '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])), + '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])), + '__YEAR__' => (string) $tmp['year'], + '__PREVIOUS_DAY__' => (string) $tmp2['day'], + '__PREVIOUS_MONTH__' => (string) $tmp3['month'], + '__PREVIOUS_YEAR__' => (string) ($tmp['year'] - 1), + '__NEXT_DAY__' => (string) $tmp4['day'], + '__NEXT_MONTH__' => (string) $tmp5['month'], + '__NEXT_YEAR__' => (string) ($tmp['year'] + 1), + )); + } + + if (! empty($conf->multicompany->enabled)) + { + $substitutionarray=array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity)); + } + if (empty($exclude) || ! in_array('system', $exclude)) + { + $substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT; + $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationOfKey'); + $substitutionarray['__[AnyConstantKey]__']=$outputlangs->trans('ValueOfConstantKey'); + } + + return $substitutionarray; +} + +/** + * Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval), + * and texts like __(TranslationKey|langfile)__ and __[ConstantKey]__ are also replaced. + * Example of usage: + * $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $thirdparty); + * complete_substitutions_array($substitutionarray, $langs, $thirdparty); + * $mesg = make_substitutions($mesg, $substitutionarray, $langs); + * + * @param string $text Source string in which we must do substitution + * @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...) + * @param Translate $outputlangs Output language + * @return string Output string after substitutions + * @see complete_substitutions_array, getCommonSubstitutionArray + */ +function make_substitutions($text, $substitutionarray, $outputlangs = null) +{ + global $conf, $langs; + + if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; + + if (empty($outputlangs)) $outputlangs=$langs; + + // Make substitution for language keys + if (is_object($outputlangs)) + { + while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) + { + $msgishtml = 0; + if (dol_textishtml($text, 1)) $msgishtml = 1; + + // If key is __(TranslationKey|langfile)__, then force load of langfile.lang + $tmp=explode('|', $reg[1]); + if (! empty($tmp[1])) $outputlangs->load($tmp[1]); + + $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text); + } + } + + // Make substitution for constant keys. Must be after the substitution of translation, so if text of translation contains a constant, + // it is also converted. + while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) + { + $msgishtml = 0; + if (dol_textishtml($text, 1)) $msgishtml = 1; + + $keyfound = $reg[1]; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); + } + + // Make substitition for array $substitutionarray + foreach ($substitutionarray as $key => $value) + { + if (! isset($value)) continue; // If value is null, it same than not having substitution key at all into array, we do not replace. + + if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection + if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection + + $text=str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example + } + + return $text; +} + +/** + * Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array. + * In this case, method completesubstitutionarray provided by module is called. + * + * @param array $substitutionarray Array substitution old value => new value value + * @param Translate $outputlangs Output language + * @param Object $object Source object + * @param mixed $parameters Add more parameters (useful to pass product lines) + * @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray) + * @return void + * @see make_substitutions + */ +function complete_substitutions_array(&$substitutionarray, $outputlangs, $object = null, $parameters = null, $callfunc = "completesubstitutionarray") +{ + global $conf,$user; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Add a substitution key for each extrafields, using key __EXTRA_XXX__ + // TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array. + /*if (is_object($object) && is_array($object->array_options)) + { + foreach($object->array_options as $key => $val) + { + $keyshort=preg_replace('/^(options|extra)_/','',$key); + $substitutionarray['__EXTRAFIELD_'.$keyshort.'__']=$val; + // For backward compatibiliy + $substitutionarray['%EXTRA_'.$keyshort.'%']=$val; + } + }*/ + + // Check if there is external substitution to do, requested by plugins + $dirsubstitutions=array_merge(array(), (array) $conf->modules_parts['substitutions']); + + foreach($dirsubstitutions as $reldir) + { + $dir=dol_buildpath($reldir, 0); + + // Check if directory exists + if (! dol_is_dir($dir)) continue; + + $substitfiles=dol_dir_list($dir, 'files', 0, 'functions_'); + foreach($substitfiles as $substitfile) + { + if (preg_match('/functions_(.*)\.lib\.php/i', $substitfile['name'], $reg)) + { + $module=$reg[1]; + + dol_syslog("Library ".$substitfile['name']." found into ".$dir); + // Include the user's functions file + require_once $dir.$substitfile['name']; + // Call the user's function, and only if it is defined + $function_name=$module."_".$callfunc; + if (function_exists($function_name)) $function_name($substitutionarray, $outputlangs, $object, $parameters); + } + } + } +} + +/** + * Format output for start and end date + * + * @param int $date_start Start date + * @param int $date_end End date + * @param string $format Output format + * @param Translate $outputlangs Output language + * @return void + */ +function print_date_range($date_start, $date_end, $format = '', $outputlangs = '') +{ + print get_date_range($date_start, $date_end, $format, $outputlangs); +} + +/** + * Format output for start and end date + * + * @param int $date_start Start date + * @param int $date_end End date + * @param string $format Output format + * @param Translate $outputlangs Output language + * @param integer $withparenthesis 1=Add parenthesis, 0=non parenthesis + * @return string String + */ +function get_date_range($date_start, $date_end, $format = '', $outputlangs = '', $withparenthesis = 1) +{ + global $langs; + + $out=''; + + if (! is_object($outputlangs)) $outputlangs=$langs; + + if ($date_start && $date_end) + { + $out.= ($withparenthesis?' (':'').$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis?')':''); + } + if ($date_start && ! $date_end) + { + $out.= ($withparenthesis?' (':'').$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)).($withparenthesis?')':''); + } + if (! $date_start && $date_end) + { + $out.= ($withparenthesis?' (':'').$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis?')':''); + } + + return $out; +} + +/** + * Return firstname and lastname in correct order + * + * @param string $firstname Firstname + * @param string $lastname Lastname + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname, 3=Firstname if defined else lastname + * @return string Firstname + lastname or Lastname + firstname + */ +function dolGetFirstLastname($firstname, $lastname, $nameorder = -1) +{ + global $conf; + + $ret=''; + // If order not defined, we use the setup + if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?1:0); + if ($nameorder && $nameorder != 2 && $nameorder != 3) + { + $ret.=$firstname; + if ($firstname && $lastname) $ret.=' '; + $ret.=$lastname; + } + elseif ($nameorder == 2 || $nameorder == 3) + { + $ret.=$firstname; + if (empty($ret) && $nameorder == 3) + { + $ret.=$lastname; + } + } + else + { + $ret.=$lastname; + if ($firstname && $lastname) $ret.=' '; + $ret.=$firstname; + } + return $ret; +} + + +/** + * Set event message in dol_events session object. Will be output by calling dol_htmloutput_events. + * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. + * Note: Prefer to use setEventMessages instead. + * + * @param mixed $mesgs Message string or array + * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') + * @return void + * @see dol_htmloutput_events + */ +function setEventMessage($mesgs, $style = 'mesgs') +{ + //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function + if (! is_array($mesgs)) // If mesgs is a string + { + if ($mesgs) $_SESSION['dol_events'][$style][] = $mesgs; + } + else // If mesgs is an array + { + foreach($mesgs as $mesg) + { + if ($mesg) $_SESSION['dol_events'][$style][] = $mesg; + } + } +} + +/** + * Set event messages in dol_events session object. Will be output by calling dol_htmloutput_events. + * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. + * + * @param string $mesg Message string + * @param array $mesgs Message array + * @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') + * @return void + * @see dol_htmloutput_events + */ +function setEventMessages($mesg, $mesgs, $style = 'mesgs') +{ + if (empty($mesg) && empty($mesgs)) + { + dol_syslog("Try to add a message in stack with empty message", LOG_WARNING); + } + else + { + if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages'); + if (empty($mesgs)) setEventMessage($mesg, $style); + else + { + if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array + setEventMessage($mesgs, $style); + } + } +} + +/** + * Print formated messages to output (Used to show messages on html output). + * Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function, so there is + * no need to call it explicitely. + * + * @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them + * @return void + * @see dol_htmloutput_mesg + */ +function dol_htmloutput_events($disabledoutputofmessages = 0) +{ + // Show mesgs + if (isset($_SESSION['dol_events']['mesgs'])) { + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); + unset($_SESSION['dol_events']['mesgs']); + } + + // Show errors + if (isset($_SESSION['dol_events']['errors'])) { + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); + unset($_SESSION['dol_events']['errors']); + } + + // Show warnings + if (isset($_SESSION['dol_events']['warnings'])) { + if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); + unset($_SESSION['dol_events']['warnings']); + } +} + +/** + * Get formated messages to output (Used to show messages on html output). + * This include also the translation of the message key. + * + * @param string $mesgstring Message string or message key + * @param string[] $mesgarray Array of message strings or message keys + * @param string $style Style of message output ('ok' or 'error') + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return string Return html output + * + * @see dol_print_error + * @see dol_htmloutput_errors + * @see setEventMessages + */ +function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $keepembedded = 0) +{ + global $conf, $langs; + + $ret=0; $return=''; + $out=''; + $divstart=$divend=''; + + // If inline message with no format, we add it. + if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
    /i', $out)) + { + $divstart='
    '; + $divend='
    '; + } + + if ((is_array($mesgarray) && count($mesgarray)) || $mesgstring) + { + $langs->load("errors"); + $out.=$divstart; + if (is_array($mesgarray) && count($mesgarray)) + { + foreach($mesgarray as $message) + { + $ret++; + $out.= $langs->trans($message); + if ($ret < count($mesgarray)) $out.= "
    \n"; + } + } + if ($mesgstring) + { + $langs->load("errors"); + $ret++; + $out.= $langs->trans($mesgstring); + } + $out.=$divend; + } + + if ($out) + { + if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) + { + $return = ''; + } + else + { + $return = $out; + } + } + + return $return; +} + +/** + * Get formated error messages to output (Used to show messages on html output). + * + * @param string $mesgstring Error message + * @param array $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return string Return html output + * + * @see dol_print_error + * @see dol_htmloutput_mesg + */ +function get_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0) +{ + return get_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded); +} + +/** + * Print formated messages to output (Used to show messages on html output). + * + * @param string $mesgstring Message string or message key + * @param string[] $mesgarray Array of message strings or message keys + * @param string $style Which style to use ('ok', 'warning', 'error') + * @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify) + * @return void + * + * @see dol_print_error + * @see dol_htmloutput_errors + * @see setEventMessages + */ +function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0) +{ + if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return; + + $iserror=0; + $iswarning=0; + if (is_array($mesgarray)) + { + foreach($mesgarray as $val) + { + if ($val && preg_match('/class="error"/i', $val)) { $iserror++; break; } + if ($val && preg_match('/class="warning"/i', $val)) { $iswarning++; break; } + } + } + elseif ($mesgstring && preg_match('/class="error"/i', $mesgstring)) $iserror++; + elseif ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) $iswarning++; + if ($style=='error') $iserror++; + if ($style=='warning') $iswarning++; + + if ($iserror || $iswarning) + { + // Remove div from texts + $mesgstring=preg_replace('/<\/div>
    /', '
    ', $mesgstring); + $mesgstring=preg_replace('/
    /', '', $mesgstring); + $mesgstring=preg_replace('/<\/div>/', '', $mesgstring); + // Remove div from texts array + if (is_array($mesgarray)) + { + $newmesgarray=array(); + foreach($mesgarray as $val) + { + $tmpmesgstring=preg_replace('/<\/div>
    /', '
    ', $val); + $tmpmesgstring=preg_replace('/
    /', '', $tmpmesgstring); + $tmpmesgstring=preg_replace('/<\/div>/', '', $tmpmesgstring); + $newmesgarray[]=$tmpmesgstring; + } + $mesgarray=$newmesgarray; + } + print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror?'error':'warning'), $keepembedded); + } + else print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); +} + +/** + * Print formated error messages to output (Used to show messages on html output). + * + * @param string $mesgstring Error message + * @param array $mesgarray Error messages array + * @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify) + * @return void + * + * @see dol_print_error + * @see dol_htmloutput_mesg + */ +function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0) +{ + dol_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded); +} + +/** + * Advanced sort array by second index function, which produces ascending (default) + * or descending output and uses optionally natural case insensitive sorting (which + * can be optionally case sensitive as well). + * + * @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...)) + * @param string $index Key in array to use for sorting criteria + * @param int $order Sort order ('asc' or 'desc') + * @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort) + * @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive + * @param int $keepindex If 0 and index key of array to sort is a numeric, than index will be rewrote. If 1 or index key is not numeric, key for index is kept after sorting. + * @return array Sorted array + */ +function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sensitive = 0, $keepindex = 0) +{ + // Clean parameters + $order=strtolower($order); + + if (is_array($array)) + { + $sizearray=count($array); + if ($sizearray>0) + { + $temp = array(); + foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; + + if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); + else + { + ($case_sensitive) ? natsort($temp) : natcasesort($temp); + if($order!='asc') $temp=array_reverse($temp, true); + } + + $sorted = array(); + + foreach(array_keys($temp) as $key) + { + (is_numeric($key) && empty($keepindex)) ? $sorted[]=$array[$key] : $sorted[$key]=$array[$key]; + } + + return $sorted; + } + } + return $array; +} + + +/** + * Check if a string is in UTF8 + * + * @param string $str String to check + * @return boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary) + */ +function utf8_check($str) +{ + // We must use here a binary strlen function (so not dol_strlen) + $strLength = dol_strlen($str); + for ($i=0; $i<$strLength; $i++) + { + if (ord($str[$i]) < 0x80) continue; // 0bbbbbbb + elseif ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; // 110bbbbb + elseif ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; // 1110bbbb + elseif ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; // 11110bbb + elseif ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; // 111110bb + elseif ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; // 1111110b + else return false; // Does not match any model + for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? + if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) + return false; + } + } + return true; +} + + +/** + * Return a string encoded into OS filesystem encoding. This function is used to define + * value to pass to filesystem PHP functions. + * + * @param string $str String to encode (UTF-8) + * @return string Encoded string (UTF-8, ISO-8859-1) + */ +function dol_osencode($str) +{ + global $conf; + + $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 + if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows + if (empty($tmp)) $tmp='utf-8'; // By default for other + if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; + + if ($tmp == 'iso-8859-1') return utf8_decode($str); + return $str; +} + + +/** + * Return an id or code from a code or id. + * Store also Code-Id into a cache to speed up next request on same key. + * + * @param DoliDB $db Database handler + * @param string $key Code or Id to get Id or Code + * @param string $tablename Table name without prefix + * @param string $fieldkey Field to search the key into + * @param string $fieldid Field to get + * @param int $entityfilter Filter by entity + * @return int <0 if KO, Id of code if OK + * @see $langs->getLabelFromKey + */ +function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0) +{ + global $cache_codes; + + // If key empty + if ($key == '') return ''; + + // Check in cache + if (isset($cache_codes[$tablename][$key][$fieldid])) // Can be defined to 0 or '' + { + return $cache_codes[$tablename][$key][$fieldid]; // Found in cache + } + + dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG); + + $sql = "SELECT ".$fieldid." as valuetoget"; + $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; + $sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; + if (! empty($entityfilter)) + $sql.= " AND entity IN (" . getEntity($tablename) . ")"; + + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $cache_codes[$tablename][$key][$fieldid]=$obj->valuetoget; + else $cache_codes[$tablename][$key][$fieldid]=''; + $db->free($resql); + return $cache_codes[$tablename][$key][$fieldid]; + } + else + { + return -1; + } +} + +/** + * Verify if condition in string is ok or not + * + * @param string $strRights String with condition to check + * @return boolean True or False. Return True if strRights is '' + */ +function verifCond($strRights) +{ + global $user,$conf,$langs; + global $leftmenu; + global $rights; // To export to dol_eval function + + //print $strRights."
    \n"; + $rights = true; + if ($strRights != '') + { + $str = 'if(!(' . $strRights . ')) { $rights = false; }'; + dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition + } + return $rights; +} + +/** + * Replace eval function to add more security. + * This function is called by verifCond() or trans() and transnoentitiesnoconv(). + * + * @param string $s String to evaluate + * @param int $returnvalue 0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)). + * @param int $hideerrors 1=Hide errors + * @return mixed Nothing or return of eval + */ +function dol_eval($s, $returnvalue = 0, $hideerrors = 1) +{ + // Only global variables can be changed by eval function and returned to caller + global $db, $langs, $user, $conf, $website, $websitepage; + global $action, $mainmenu, $leftmenu; + global $rights; + global $object; + global $mysoc; + + global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object + global $soc; // For backward compatibility + + //print $s."
    \n"; + if ($returnvalue) + { + if ($hideerrors) return @eval('return '.$s.';'); + else return eval('return '.$s.';'); + } + else + { + if ($hideerrors) @eval($s); + else eval($s); + } +} + +/** + * Return if var element is ok + * + * @param string $element Variable to check + * @return boolean Return true of variable is not empty + */ +function dol_validElement($element) +{ + return (trim($element) != ''); +} + +/** + * Return img flag of country for a language code or country code + * + * @param string $codelang Language code (en_IN, fr_CA...) or Country code (IN, FR) + * @param string $moreatt Add more attribute on img tag (For example 'style="float: right"') + * @return string HTML img string with flag. + */ +function picto_from_langcode($codelang, $moreatt = '') +{ + global $langs; + + if (empty($codelang)) return ''; + + if ($codelang == 'auto') + { + return ''; + } + + $langtocountryflag = array( + 'ar_AR' => '', + 'ca_ES' => 'catalonia', + 'da_DA' => 'dk', + 'fr_CA' => 'mq', + 'sv_SV' => 'se' + ); + + if (isset($langtocountryflag[$codelang])) $flagImage = $langtocountryflag[$codelang]; + else + { + $tmparray = explode('_', $codelang); + $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; + } + + return img_picto_common($codelang, 'flags/'.strtolower($flagImage).'.png', $moreatt); +} + +/** + * Return default language from country code + * + * @param string $countrycode Country code like 'US', 'FR', 'CA', ... + * @return string Value of locale like 'en_US', 'fr_FR', ... + */ +function getLanguageCodeFromCountryCode($countrycode) +{ + global $mysoc; + + if (strtoupper($countrycode) == 'MQ') return 'fr_CA'; + if (strtoupper($countrycode) == 'SE') return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country + if (strtoupper($countrycode) == 'CH') + { + if ($mysoc->country_code == 'FR') return 'fr_CH'; + if ($mysoc->country_code == 'DE') return 'de_CH'; + } + + // Locale list taken from: + // http://stackoverflow.com/questions/3191664/ + // list-of-all-locales-and-their-short-codes + $locales = array( + 'af-ZA', + 'am-ET', + 'ar-AE', + 'ar-BH', + 'ar-DZ', + 'ar-EG', + 'ar-IQ', + 'ar-JO', + 'ar-KW', + 'ar-LB', + 'ar-LY', + 'ar-MA', + 'ar-OM', + 'ar-QA', + 'ar-SA', + 'ar-SY', + 'ar-TN', + 'ar-YE', + 'as-IN', + 'ba-RU', + 'be-BY', + 'bg-BG', + 'bn-BD', + 'bn-IN', + 'bo-CN', + 'br-FR', + 'ca-ES', + 'co-FR', + 'cs-CZ', + 'cy-GB', + 'da-DK', + 'de-AT', + 'de-CH', + 'de-DE', + 'de-LI', + 'de-LU', + 'dv-MV', + 'el-GR', + 'en-AU', + 'en-BZ', + 'en-CA', + 'en-GB', + 'en-IE', + 'en-IN', + 'en-JM', + 'en-MY', + 'en-NZ', + 'en-PH', + 'en-SG', + 'en-TT', + 'en-US', + 'en-ZA', + 'en-ZW', + 'es-AR', + 'es-BO', + 'es-CL', + 'es-CO', + 'es-CR', + 'es-DO', + 'es-EC', + 'es-ES', + 'es-GT', + 'es-HN', + 'es-MX', + 'es-NI', + 'es-PA', + 'es-PE', + 'es-PR', + 'es-PY', + 'es-SV', + 'es-US', + 'es-UY', + 'es-VE', + 'et-EE', + 'eu-ES', + 'fa-IR', + 'fi-FI', + 'fo-FO', + 'fr-BE', + 'fr-CA', + 'fr-CH', + 'fr-FR', + 'fr-LU', + 'fr-MC', + 'fy-NL', + 'ga-IE', + 'gd-GB', + 'gl-ES', + 'gu-IN', + 'he-IL', + 'hi-IN', + 'hr-BA', + 'hr-HR', + 'hu-HU', + 'hy-AM', + 'id-ID', + 'ig-NG', + 'ii-CN', + 'is-IS', + 'it-CH', + 'it-IT', + 'ja-JP', + 'ka-GE', + 'kk-KZ', + 'kl-GL', + 'km-KH', + 'kn-IN', + 'ko-KR', + 'ky-KG', + 'lb-LU', + 'lo-LA', + 'lt-LT', + 'lv-LV', + 'mi-NZ', + 'mk-MK', + 'ml-IN', + 'mn-MN', + 'mr-IN', + 'ms-BN', + 'ms-MY', + 'mt-MT', + 'nb-NO', + 'ne-NP', + 'nl-BE', + 'nl-NL', + 'nn-NO', + 'oc-FR', + 'or-IN', + 'pa-IN', + 'pl-PL', + 'ps-AF', + 'pt-BR', + 'pt-PT', + 'rm-CH', + 'ro-RO', + 'ru-RU', + 'rw-RW', + 'sa-IN', + 'se-FI', + 'se-NO', + 'se-SE', + 'si-LK', + 'sk-SK', + 'sl-SI', + 'sq-AL', + 'sv-FI', + 'sv-SE', + 'sw-KE', + 'ta-IN', + 'te-IN', + 'th-TH', + 'tk-TM', + 'tn-ZA', + 'tr-TR', + 'tt-RU', + 'ug-CN', + 'uk-UA', + 'ur-PK', + 'vi-VN', + 'wo-SN', + 'xh-ZA', + 'yo-NG', + 'zh-CN', + 'zh-HK', + 'zh-MO', + 'zh-SG', + 'zh-TW', + 'zu-ZA', + ); + + $buildprimarykeytotest = strtolower($countrycode).'-'.strtoupper($countrycode); + if (in_array($buildprimarykeytotest, $locales)) return strtolower($countrycode).'_'.strtoupper($countrycode); + + foreach ($locales as $locale) + { + $locale_language = locale_get_primary_language($locale); + $locale_region = locale_get_region($locale); + if (strtoupper($countrycode) == $locale_region) + { + //var_dump($locale.'-'.$locale_language.'-'.$locale_region); + return strtolower($locale_language).'_'.strtoupper($locale_region); + } + } + + return null; +} + +/** + * Complete or removed entries into a head array (used to build tabs). + * For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab']. + * Or by change using hook completeTabsHead + * + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param object|null $object Object object + * @param array $head Object head + * @param int $h New position to fill + * @param string $type Value for object where objectvalue can be + * 'thirdparty' to add a tab in third party view + * 'intervention' to add a tab in intervention view + * 'supplier_order' to add a tab in supplier order view + * 'supplier_invoice' to add a tab in supplier invoice view + * 'invoice' to add a tab in customer invoice view + * 'order' to add a tab in customer order view + * 'contract' to add a tabl in contract view + * 'product' to add a tab in product view + * 'propal' to add a tab in propal view + * 'user' to add a tab in user view + * 'group' to add a tab in group view + * 'member' to add a tab in fundation member view + * 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member) + * 'ecm' to add a tab for another ecm view + * 'stock' to add a tab for warehouse view + * @param string $mode 'add' to complete head, 'remove' to remove entries + * @return void + */ +function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode = 'add') +{ + global $hookmanager; + + if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type])) + { + foreach ($conf->modules_parts['tabs'][$type] as $value) + { + $values=explode(':', $value); + + if ($mode == 'add' && ! preg_match('/^\-/', $values[1])) + { + if (count($values) == 6) // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__' + { + if ($values[0] != $type) continue; + + if (verifCond($values[4])) + { + if ($values[3]) $langs->load($values[3]); + if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) + { + $substitutionarray=array(); + complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey'=>$values[2])); + $label=make_substitutions($reg[1], $substitutionarray); + } + else $label=$langs->trans($values[2]); + + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && ! empty($object->id))?$object->id:''), $values[5]), 1); + $head[$h][1] = $label; + $head[$h][2] = str_replace('+', '', $values[1]); + $h++; + } + } + elseif (count($values) == 5) // deprecated + { + dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING); + + if ($values[0] != $type) continue; + if ($values[3]) $langs->load($values[3]); + if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) + { + $substitutionarray=array(); + complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey'=>$values[2])); + $label=make_substitutions($reg[1], $substitutionarray); + } + else $label=$langs->trans($values[2]); + + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && ! empty($object->id))?$object->id:''), $values[4]), 1); + $head[$h][1] = $label; + $head[$h][2] = str_replace('+', '', $values[1]); + $h++; + } + } + elseif ($mode == 'remove' && preg_match('/^\-/', $values[1])) + { + if ($values[0] != $type) continue; + $tabname=str_replace('-', '', $values[1]); + foreach($head as $key => $val) + { + $condition = (! empty($values[3]) ? verifCond($values[3]) : 1); + //var_dump($key.' - '.$tabname.' - '.$head[$key][2].' - '.$values[3].' - '.$condition); + if ($head[$key][2]==$tabname && $condition) + { + unset($head[$key]); + break; + } + } + } + } + } + + // No need to make a return $head. Var is modified as a reference + if (! empty($hookmanager)) + { + $parameters=array('object' => $object, 'mode' => $mode, 'head' => $head); + $reshook=$hookmanager->executeHooks('completeTabsHead', $parameters); + if ($reshook > 0) + { + $head = $hookmanager->resArray; + $h = count($head); + } + } +} + +/** + * Print common footer : + * conf->global->MAIN_HTML_FOOTER + * js for switch of menu hider + * js for conf->global->MAIN_GOOGLE_AN_ID + * js for conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"] + * js for conf->logbuffer + * + * @param string $zone 'private' (for private pages) or 'public' (for public pages) + * @return void + */ +function printCommonFooter($zone = 'private') +{ + global $conf, $hookmanager, $user; + global $action; + global $micro_start_time; + + if ($zone == 'private') print "\n".''."\n"; + else print "\n".''."\n"; + + // A div to store page_y POST parameter so we can read it using javascript + print "\n\n"; + print ''."\n"; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; + + print "\n"; + if (! empty($conf->use_javascript_ajax)) + { + print ''."\n"; + } + + // Add Xdebug coverage of code + if (defined('XDEBUGCOVERAGE')) + { + print_r(xdebug_get_code_coverage()); + } + + // If there is some logs in buffer to show + if (count($conf->logbuffer)) + { + print "\n"; + print "\n"; + } + } +} + +/** + * Split a string with 2 keys into key array. + * For example: "A=1;B=2;C=2" is exploded into array('A'=>1,'B'=>2,'C'=>3) + * + * @param string $string String to explode + * @param string $delimiter Delimiter between each couple of data + * @param string $kv Delimiter between key and value + * @return array Array of data exploded + */ +function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') +{ + if ($a = explode($delimiter, $string)) + { + $ka = array(); + foreach ($a as $s) { // each part + if ($s) { + if ($pos = strpos($s, $kv)) { // key/value delimiter + $ka[trim(substr($s, 0, $pos))] = trim(substr($s, $pos + strlen($kv))); + } else { // key delimiter not found + $ka[] = trim($s); + } + } + } + return $ka; + } + return array(); +} + + +/** + * Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag) + * + * @param string $selector Selector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. + * @return string HTML code to set focus + */ +function dol_set_focus($selector) +{ + print "\n".''."\n"; + print ''."\n"; +} + + +/** + * Return getmypid() or random PID when function is disabled + * Some web hosts disable this php function for security reasons + * and sometimes we can't redeclare function + * + * @return int + */ +function dol_getmypid() +{ + if (! function_exists('getmypid')) { + return mt_rand(1, 32768); + } else { + return getmypid(); + } +} + + +/** + * Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) + * + * @param string|string[] $fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2") + * @param string $value The value to look for. + * If param $mode is 0, can contains several keywords separated with a space or | + * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 + * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 + * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" + * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" + * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" + * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') + * 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '1,3,4') for search into a multiselect string ('1,2') + * @param integer $nofirstand 1=Do not output the first 'AND' + * @return string $res The statement to append to the SQL query + */ +function natural_search($fields, $value, $mode = 0, $nofirstand = 0) +{ + global $db,$langs; + + $value=trim($value); + + if ($mode == 0) + { + $value=preg_replace('/\*/', '%', $value); // Replace * with % + } + if ($mode == 1) + { + $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + } + + $value = preg_replace('/\s*\|\s*/', '|', $value); + + $crits = explode(' ', $value); + $res = ''; + if (! is_array($fields)) $fields = array($fields); + + $nboffields = count($fields); + $end2 = count($crits); + $j = 0; + foreach ($crits as $crit) + { + $i = 0; $i2 = 0; + $newres = ''; + foreach ($fields as $field) + { + if ($mode == 1) + { + $operator='='; + $newcrit = preg_replace('/([<>=]+)/', '', trim($crit)); + + preg_match('/([<>=]+)/', trim($crit), $reg); + if ($reg[1]) + { + $operator = $reg[1]; + } + if ($newcrit != '') + { + $numnewcrit = price2num($newcrit); + if (is_numeric($numnewcrit)) + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.$numnewcrit; + } + else + { + $newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false + } + $i2++; // a criteria was added to string + } + } + elseif ($mode == 2) + { + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")"; + $i2++; // a criteria was added to string + } + elseif ($mode == 3) + { + $tmparray=explode(',', trim($crit)); + if (count($tmparray)) + { + $listofcodes=''; + foreach($tmparray as $val) + { + if ($val) + { + $listofcodes.=($listofcodes?',':''); + $listofcodes.="'".$db->escape(trim($val))."'"; + } + } + $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")"; + $i2++; // a criteria was added to string + } + } + elseif ($mode == 4) + { + $tmparray=explode(',', trim($crit)); + if (count($tmparray)) + { + $listofcodes=''; + foreach($tmparray as $val) + { + if ($val) + { + $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\''; + $newres .= ' OR '. $field . ' = \'' . $db->escape(trim($val)) . '\''; + $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; + $newres .= ' OR '. $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; + $newres .= ')'; + $i2++; + } + } + } + } + else // $mode=0 + { + $textcrit = ''; + $tmpcrits = explode('|', $crit); + $i3 = 0; + foreach($tmpcrits as $tmpcrit) + { + if(empty($tmpcrit)) continue; + + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + + if (preg_match('/\.(id|rowid)$/', $field)) // Special case for rowid that is sometimes a ref so used as a search field + { + $newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0'); + } + else + { + $newres .= $field . " LIKE '"; + + $tmpcrit=trim($tmpcrit); + $tmpcrit2=$tmpcrit; + $tmpbefore='%'; $tmpafter='%'; + if (preg_match('/^[\^\$]/', $tmpcrit)) + { + $tmpbefore=''; + $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); + } + if (preg_match('/[\^\$]$/', $tmpcrit)) + { + $tmpafter=''; + $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); + } + $newres .= $tmpbefore; + $newres .= $db->escape($tmpcrit2); + $newres .= $tmpafter; + $newres .= "'"; + if ($tmpcrit2 == '') + { + $newres .= ' OR ' . $field . " IS NULL"; + } + } + + $i3++; + } + $i2++; // a criteria was added to string + } + $i++; + } + if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : ''); + $j++; + } + $res = ($nofirstand?"":" AND ")."(" . $res . ")"; + //print 'xx'.$res.'yy'; + return $res; +} + +/** + * Return string with full Url. The file qualified is the one defined by relative path in $object->last_main_doc + * + * @param Object $object Object + * @return string Url string + */ +function showDirectDownloadLink($object) +{ + global $conf, $langs; + + $out=''; + $url = $object->getLastMainDocLink($object->element); + + if ($url) + { + $out.= img_picto('', 'object_globe.png').' '.$langs->trans("DirectDownloadLink").'
    '; + $out.= ''; + $out.= ajax_autoselect("directdownloadlink", 0); + } + return $out; +} + +/** + * Return the filename of file to get the thumbs + * + * @param string $file Original filename (full or relative path) + * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') + * @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image (default). + * @return string New file name (full or relative path, including the thumbs/) + */ +function getImageFileNameForSize($file, $extName, $extImgTarget = '') +{ + $dirName = dirname($file); + if ($dirName == '.') $dirName=''; + + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case + $fileName = basename($fileName); + + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i', $file)?'.jpg':''); + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i', $file)?'.jpeg':''); + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i', $file)?'.gif':''); + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.png$/i', $file)?'.png':''); + if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i', $file)?'.bmp':''); + + if (! $extImgTarget) return $file; + + $subdir=''; + if ($extName) $subdir = 'thumbs/'; + + return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb +} + + +/** + * Return URL we can use for advanced preview links + * + * @param string $modulepart propal, facture, facture_fourn, ... + * @param string $relativepath Relative path of docs. + * @param int $alldata Return array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php) + * @param string $param More param on http links + * @return string|array Output string with href link or array with all components of link + */ +function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '') +{ + global $conf, $langs; + + if (empty($conf->use_javascript_ajax)) return ''; + + $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml'); + //$mime_preview[]='vnd.oasis.opendocument.presentation'; + //$mime_preview[]='archive'; + $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); + + if ($alldata == 1) + { + if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:''), 'mime'=>dol_mimetype($relativepath), ); + else return array(); + } + + // old behavior + if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; + else return ''; +} + + +/** + * Make content of an input box selected when we click into input field. + * + * @param string $htmlname Id of html object + * @param string $addlink Add a 'link to' after + * @return string + */ +function ajax_autoselect($htmlname, $addlink = '') +{ + global $langs; + $out = ''; + if ($addlink) $out.='
    '.$langs->trans("Link").''; + return $out; +} + + +/** + * Return mime type of a file + * + * @param string $file Filename we looking for MIME type + * @param string $default Default mime type if extension not found in known list + * @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa + * @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive) + * @see image_format_supported (images.lib.php) + */ +function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) +{ + $mime=$default; + $imgmime='other.png'; + $famime='file-o'; + $srclang=''; + + $tmpfile=preg_replace('/\.noexe$/', '', $file); + + // Text files + if (preg_match('/\.txt$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; } + if (preg_match('/\.rtx$/i', $tmpfile)) { $mime='text/richtext'; $imgmime='text.png'; $famime='file-text-o'; } + if (preg_match('/\.csv$/i', $tmpfile)) { $mime='text/csv'; $imgmime='text.png'; $famime='file-text-o'; } + if (preg_match('/\.tsv$/i', $tmpfile)) { $mime='text/tab-separated-values'; $imgmime='text.png'; $famime='file-text-o'; } + if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; } + if (preg_match('/\.ini$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='ini'; $famime='file-text-o'; } + if (preg_match('/\.css$/i', $tmpfile)) { $mime='text/css'; $imgmime='css.png'; $srclang='css'; $famime='file-text-o'; } + // Certificate files + if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; } + // HTML/XML + if (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { $mime='text/html'; $imgmime='html.png'; $srclang='html'; $famime='file-text-o'; } + if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { $mime='text/xml'; $imgmime='other.png'; $srclang='xml'; $famime='file-text-o'; } + // Languages + if (preg_match('/\.bas$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='bas'; $famime='file-code-o'; } + if (preg_match('/\.(c)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='c'; $famime='file-code-o'; } + if (preg_match('/\.(cpp)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='cpp'; $famime='file-code-o'; } + if (preg_match('/\.(h)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='h'; $famime='file-code-o'; } + if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='java'; $famime='file-code-o'; } + if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; $famime='file-code-o'; } + if (preg_match('/\.phtml$/i', $tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; $famime='file-code-o'; } + if (preg_match('/\.(pl|pm)$/i', $tmpfile)) { $mime='text/plain'; $imgmime='pl.png'; $srclang='perl'; $famime='file-code-o'; } + if (preg_match('/\.sql$/i', $tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='sql'; $famime='file-code-o'; } + if (preg_match('/\.js$/i', $tmpfile)) { $mime='text/x-javascript'; $imgmime='jscript.png'; $srclang='js'; $famime='file-code-o'; } + // Open office + if (preg_match('/\.odp$/i', $tmpfile)) { $mime='application/vnd.oasis.opendocument.presentation'; $imgmime='ooffice.png'; $famime='file-powerpoint-o'; } + if (preg_match('/\.ods$/i', $tmpfile)) { $mime='application/vnd.oasis.opendocument.spreadsheet'; $imgmime='ooffice.png'; $famime='file-excel-o'; } + if (preg_match('/\.odt$/i', $tmpfile)) { $mime='application/vnd.oasis.opendocument.text'; $imgmime='ooffice.png'; $famime='file-word-o'; } + // MS Office + if (preg_match('/\.mdb$/i', $tmpfile)) { $mime='application/msaccess'; $imgmime='mdb.png'; $famime='file-o'; } + if (preg_match('/\.doc(x|m)?$/i', $tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; $famime='file-word-o'; } + if (preg_match('/\.dot(x|m)?$/i', $tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; $famime='file-word-o'; } + if (preg_match('/\.xlt(x)?$/i', $tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; } + if (preg_match('/\.xla(m)?$/i', $tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; } + if (preg_match('/\.xls$/i', $tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; } + if (preg_match('/\.xls(b|m|x)$/i', $tmpfile)) { $mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime='xls.png'; $famime='file-excel-o'; } + if (preg_match('/\.pps(m|x)?$/i', $tmpfile)) { $mime='application/vnd.ms-powerpoint'; $imgmime='ppt.png'; $famime='file-powerpoint-o'; } + if (preg_match('/\.ppt(m|x)?$/i', $tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; $famime='file-powerpoint-o'; } + // Other + if (preg_match('/\.pdf$/i', $tmpfile)) { $mime='application/pdf'; $imgmime='pdf.png'; $famime='file-pdf-o'; } + // Scripts + if (preg_match('/\.bat$/i', $tmpfile)) { $mime='text/x-bat'; $imgmime='script.png'; $srclang='dos'; $famime='file-code-o'; } + if (preg_match('/\.sh$/i', $tmpfile)) { $mime='text/x-sh'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; } + if (preg_match('/\.ksh$/i', $tmpfile)) { $mime='text/x-ksh'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; } + if (preg_match('/\.bash$/i', $tmpfile)) { $mime='text/x-bash'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; } + // Images + if (preg_match('/\.ico$/i', $tmpfile)) { $mime='image/x-icon'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) { $mime='image/jpeg'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.png$/i', $tmpfile)) { $mime='image/png'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.gif$/i', $tmpfile)) { $mime='image/gif'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.bmp$/i', $tmpfile)) { $mime='image/bmp'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.(tif|tiff)$/i', $tmpfile)) { $mime='image/tiff'; $imgmime='image.png'; $famime='file-image-o'; } + if (preg_match('/\.svg$/i', $tmpfile)) { $mime='image/svg+xml';$imgmime='image.png'; $famime='file-image-o'; } + // Calendar + if (preg_match('/\.vcs$/i', $tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; $famime='file-text-o'; } + if (preg_match('/\.ics$/i', $tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; $famime='file-text-o'; } + // Other + if (preg_match('/\.torrent$/i', $tmpfile)) { $mime='application/x-bittorrent'; $imgmime='other.png'; $famime='file-o'; } + // Audio + if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { $mime='audio'; $imgmime='audio.png'; $famime='file-audio-o'; } + // Video + if (preg_match('/\.ogv$/i', $tmpfile)) { $mime='video/ogg'; $imgmime='video.png'; $famime='file-video-o'; } + if (preg_match('/\.webm$/i', $tmpfile)) { $mime='video/webm'; $imgmime='video.png'; $famime='file-video-o'; } + if (preg_match('/\.avi$/i', $tmpfile)) { $mime='video/x-msvideo'; $imgmime='video.png'; $famime='file-video-o'; } + if (preg_match('/\.divx$/i', $tmpfile)) { $mime='video/divx'; $imgmime='video.png'; $famime='file-video-o'; } + if (preg_match('/\.xvid$/i', $tmpfile)) { $mime='video/xvid'; $imgmime='video.png'; $famime='file-video-o'; } + if (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) { $mime='video'; $imgmime='video.png'; $famime='file-video-o'; } + // Archive + if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i', $tmpfile)) { $mime='archive'; $imgmime='archive.png'; $famime='file-archive-o'; } // application/xxx where zzz is zip, ... + // Exe + if (preg_match('/\.(exe|com)$/i', $tmpfile)) { $mime='application/octet-stream'; $imgmime='other.png'; $famime='file-o'; } + // Lib + if (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { $mime='library'; $imgmime='library.png'; $famime='file-o'; } + // Err + if (preg_match('/\.err$/i', $tmpfile)) { $mime='error'; $imgmime='error.png'; $famime='file-text-o'; } + + // Return string + if ($mode == 1) + { + $tmp=explode('/', $mime); + return (! empty($tmp[1])?$tmp[1]:$tmp[0]); + } + if ($mode == 2) + { + return $imgmime; + } + if ($mode == 3) + { + return $srclang; + } + if ($mode == 4) + { + return $famime; + } + return $mime; +} + +/** + * Return value from dictionary + * + * @param string $tablename name of dictionary + * @param string $field the value to return + * @param int $id id of line + * @param bool $checkentity add filter on entity + * @param string $rowidfield name of the column rowid + * @return string + */ +function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid') +{ + global $dictvalues,$db,$langs; + + if (!isset($dictvalues[$tablename])) + { + $dictvalues[$tablename] = array(); + $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; + if ($checkentity) $sql.= ' AND entity IN (0,'.getEntity($tablename).')'; + + $resql = $db->query($sql); + if ($resql) + { + while ($obj = $db->fetch_object($resql)) + { + $dictvalues[$tablename][$obj->{$rowidfield}] = $obj; + } + } + else + { + dol_print_error($db); + } + } + + if (!empty($dictvalues[$tablename][$id])) return $dictvalues[$tablename][$id]->{$field}; // Found + else // Not found + { + if ($id > 0) return $id; + return ''; + } +} + +/** + * Return true if the color is light + * + * @param string $stringcolor String with hex (FFFFFF) or comma RGB ('255,255,255') + * @return int -1 : Error with argument passed |0 : color is dark | 1 : color is light + */ +function colorIsLight($stringcolor) +{ + $res = -1; + if (!empty($stringcolor)) + { + $res = 0; + $tmp=explode(',', $stringcolor); + if (count($tmp) > 1) // This is a comma RGB ('255','255','255') + { + $r = $tmp[0]; + $g = $tmp[1]; + $b = $tmp[2]; + } + else + { + $hexr=$stringcolor[0].$stringcolor[1]; + $hexg=$stringcolor[2].$stringcolor[3]; + $hexb=$stringcolor[4].$stringcolor[5]; + $r = hexdec($hexr); + $g = hexdec($hexg); + $b = hexdec($hexb); + } + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $res = 1; + } + return $res; +} + +/** + * Function to test if an entry is enabled or not + * + * @param string $type_user 0=We test for internal user, 1=We test for external user + * @param array $menuentry Array for feature entry to test + * @param array $listofmodulesforexternal Array with list of modules allowed to external users + * @return int 0=Hide, 1=Show, 2=Show gray + */ +function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal) +{ + global $conf; + + //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; + //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); + if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition + if ($type_user && $menuentry['module']) + { + $tmploops=explode('|', $menuentry['module']); + $found=0; + foreach($tmploops as $tmploop) + { + if (in_array($tmploop, $listofmodulesforexternal)) { + $found++; break; + } + } + if (! $found) return 0; // Entry is for menus all excluded to external users + } + if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external + if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on + if (! $menuentry['perms']) return 2; // No permissions and user is external + return 1; +} + +/** + * Round to next multiple. + * + * @param double $n Number to round up + * @param integer $x Multiple. For example 60 to round up to nearest exact minute for a date with seconds. + * @return integer Value rounded. + */ +function roundUpToNextMultiple($n, $x = 5) +{ + return (ceil($n)%$x === 0) ? ceil($n) : round(($n+$x/2)/$x)*$x; +} diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index bb9542d69f9..6d30a300726 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1312,7 +1312,6 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } - } //} // Revenue stamp From 7c8d84aa0318f088506bd8e9d873ff7bb3c542d0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 10:27:26 +0100 Subject: [PATCH 03/77] update with html5 compliant code --- htdocs/comm/mailing/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 9fe818d72ad..4e49b7bbbbd 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -193,7 +193,7 @@ if ($result) if (! $filteremail) print ' '; print ' '; print ' '; - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; @@ -206,8 +206,8 @@ if ($result) if (! $filteremail) print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder); if (! $filteremail) print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); else print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail?"mc.statut":"m.statut"), $param, "", 'align="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], ($filteremail?"mc.statut":"m.statut"), $param, "", 'class="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -256,7 +256,7 @@ if ($result) print ''; // Status - print ''; + print ''; if ($filteremail) { print $email::libStatutDest($obj->sendstatut, 2); From eb25d12a1b0f38ed6568e0c131112d3b2a9fa18b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 10:32:33 +0100 Subject: [PATCH 04/77] update with html5 compliant code --- htdocs/comm/propal/index.php | 6 +++--- htdocs/comm/propal/list.php | 18 +++++++++--------- .../comm/propal/tpl/linkedobjectblock.tpl.php | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index fcea4ee05a6..2bc710394bb 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -430,7 +430,7 @@ if (! empty($conf->propal->enabled)) print ' '; print ''; - print ''; + print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; @@ -503,7 +503,7 @@ if (! empty($conf->propal->enabled)) print ' '; print ''; - print ''; + print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; @@ -514,7 +514,7 @@ if (! empty($conf->propal->enabled)) print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.''; - print ''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).''; + print ''.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).''; print ''; $i++; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 64c126d7e8f..67c347a97d5 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -619,21 +619,21 @@ if ($resql) if (! empty($arrayfields['p.total_ht']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } if (! empty($arrayfields['p.total_vat']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } if (! empty($arrayfields['p.total_ttc']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } @@ -670,7 +670,7 @@ if ($resql) // Status if (! empty($arrayfields['p.fk_statut']['checked'])) { - print ''; + print ''; $formpropal->selectProposalStatus($viewstatut, 1, 0, 1, 'customer', 'search_statut'); print ''; } @@ -698,9 +698,9 @@ if ($resql) if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'], $_SERVER["PHP_SELF"], 'dfv', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'], $_SERVER["PHP_SELF"], 'ddelivery', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'], $_SERVER["PHP_SELF"], 'availability', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'], $_SERVER["PHP_SELF"], 'p.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'], $_SERVER["PHP_SELF"], 'p.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); // Extra fields @@ -711,7 +711,7 @@ if ($resql) print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print ''."\n"; @@ -753,7 +753,7 @@ if ($resql) print ''; } // Other picto tool - print ''; + print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->propal->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index fc06819786a..494bb239c87 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -64,13 +64,13 @@ foreach($linkedObjectBlock as $key => $objectlink) getNomUrl(1); ?> ref_client; ?> date, 'day'); ?> - rights->propale->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + getLibStatut(3); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> Date: Mon, 4 Feb 2019 10:35:53 +0100 Subject: [PATCH 05/77] update with html5 compliant code --- htdocs/comm/card.php | 10 +++++----- htdocs/comm/prospect/index.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fd65422cdcc..79f53316e2e 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -876,7 +876,7 @@ if ($object->id > 0) print '!!!'; } - print '' . $sendingstatic->LibStatut($objp->statut, 5) . ''; + print '' . $sendingstatic->LibStatut($objp->statut, 5) . ''; print "\n"; $i++; } @@ -942,7 +942,7 @@ if ($object->id > 0) print ''.dol_print_date($db->jdate($objp->dc), 'day')."\n"; print ''.dol_print_date($db->jdate($objp->dcon), 'day')."\n"; print ' '; - print ''; + print ''; print $contrat->getLibStatut(4); print "\n"; print ''; @@ -1004,7 +1004,7 @@ if ($object->id > 0) print ''.img_object($langs->trans("ShowPropal"), "propal").' '.$objp->ref.''."\n"; //print ''.dol_print_date($db->jdate($objp->startdate)).''."\n"; print ''.convertSecondToTime($objp->duration).''."\n"; - print ''.$fichinter_static->getLibStatut(5).''."\n"; + print ''.$fichinter_static->getLibStatut(5).''."\n"; print ''; $i++; @@ -1110,7 +1110,7 @@ if ($object->id > 0) print ''; } - print ''; + print ''; print $langs->trans('FrequencyPer_'.$invoicetemplate->unit_frequency, $invoicetemplate->frequency).' - '; print ($invoicetemplate->LibStatut($invoicetemplate->frequency, $invoicetemplate->suspended, 5, 0)); print ''; @@ -1205,7 +1205,7 @@ if ($object->id > 0) print ''; } - print ''.($facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am)).''; + print ''.($facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am)).''; print "\n"; $i++; } diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 7c8c0fa0934..e110dc05b1d 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -220,7 +220,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) } if ($total>0) { - print ''.$langs->trans("Total")."".price($total).""; + print ''.$langs->trans("Total")."".price($total).""; } print "
    "; } From 577aef54e13b5da10fb7e6e09c5e2882e804c8f5 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 10:37:51 +0100 Subject: [PATCH 06/77] update with html5 compliant code --- htdocs/comm/contact.php | 2 +- htdocs/comm/index.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index e9f0a135819..68730bccef1 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -142,7 +142,7 @@ if ($resql) print ''; print ''; print ' '; - print ''; + print ''; print "\n"; $i = 0; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index f64e1328e5c..e6fc5e95010 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -186,7 +186,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'customer', 16); print ''; - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; $i++; $total += $obj->total_ht; } @@ -266,7 +266,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1, 'supplier', 16); print ''; - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; $i++; $total += $obj->total_ht; } @@ -345,10 +345,10 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print $companystatic->getNomUrl(1, 'customer', 16); print ''; if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; } else { - print ''.price($obj->total_ttc).''; + print ''.price($obj->total_ttc).''; } $i++; $total += $obj->total_ttc; @@ -432,10 +432,10 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print $companystatic->getNomUrl(1, 'supplier', 16); print ''; if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { - print ''.price($obj->total_ht).''; + print ''.price($obj->total_ht).''; } else { - print ''.price($obj->total_ttc).''; + print ''.price($obj->total_ttc).''; } $i++; $total += $obj->total_ttc; From 71e99e0972afd8be7ca392a6fe6dea16e50d3450 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 10:42:40 +0100 Subject: [PATCH 07/77] update with html5 compliant code --- htdocs/commande/customer.php | 4 ++-- htdocs/commande/list.php | 18 +++++++++--------- htdocs/commande/orderstoinvoice.php | 10 +++++----- htdocs/commande/tpl/linkedobjectblock.tpl.php | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 6e9604332f7..8b7fef878ed 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -130,7 +130,7 @@ if ($resql) print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder); print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", 'align="left"', $sortfield, $sortorder); print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'class="right"', $sortfield, $sortorder); print "\n"; // Lignes des champs de filtre @@ -149,7 +149,7 @@ if ($resql) print ''; print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 99e082d46ec..ff8940854e7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -652,21 +652,21 @@ if ($resql) if (! empty($arrayfields['c.total_ht']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } if (! empty($arrayfields['c.total_vat']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } if (! empty($arrayfields['c.total_ttc']['checked'])) { // Amount - print ''; + print ''; print ''; print ''; } @@ -691,7 +691,7 @@ if ($resql) // Status if (! empty($arrayfields['c.fk_statut']['checked'])) { - print ''; + print ''; $liststatus=array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), @@ -731,9 +731,9 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['c.date_commande']['checked'])) print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['c.date_delivery']['checked'])) print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -742,7 +742,7 @@ if ($resql) print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['c.tms']['checked'])) print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, 'align="center"', $sortfield, $sortorder, ''); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print ''."\n"; @@ -914,7 +914,7 @@ if ($resql) } print ''; - print ''; + print ''; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 4e986304828..9c6d83e3dfe 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -610,7 +610,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print_liste_field_titre('RefCustomerOrder', $_SERVER["PHP_SELF"], 'c.ref_client', '', '&socid='.$socid, '', $sortfield, $sortorder); print_liste_field_titre('OrderDate', $_SERVER["PHP_SELF"], 'c.date_commande', '', '&socid='.$socid, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('DeliveryDate', $_SERVER["PHP_SELF"], 'c.date_livraison', '', '&socid='.$socid, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre('Status', '', '', '', '', 'align="right"'); + print_liste_field_titre('Status', '', '', '', '', 'class="right"'); print_liste_field_titre('GenerateBill', '', '', '', '', 'align="center"'); print ''; @@ -638,7 +638,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; //SEARCH BUTTON - print ''; + print ''; print ''; print ''; @@ -678,7 +678,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) } print ''; - print ''; + print ''; $filename=dol_sanitizeFileName($objp->ref); $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; @@ -699,7 +699,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; // Statut - print ''.$generic_commande->LibStatut($objp->fk_statut, $objp->billed, 5).''; + print ''.$generic_commande->LibStatut($objp->fk_statut, $objp->billed, 5).''; // Checkbox print ''; @@ -718,7 +718,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) * Boutons actions */ print '
    global->INVOICE_CLOSE_ORDERS_OFF_BY_DEFAULT_FORMASSINVOICE)?' checked="checked"':'').' name="autocloseorders"> '.$langs->trans("CloseProcessedOrdersAutomatically"); - print '
    '; + print '
    '; print ''; print ''; print '
    '; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 5b2dbc890ca..cce17b32695 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -54,13 +54,13 @@ foreach($linkedObjectBlock as $key => $objectlink) getNomUrl(1); ?> ref_client; ?> date, 'day'); ?> - rights->commande->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?> - getLibStatut(3); ?> - + getLibStatut(3); ?> + element != 'shipping') { From b7605e233ee9c16aa66345b3149187cd3f4175b5 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 13:40:00 +0100 Subject: [PATCH 08/77] update with html5 compliant code --- htdocs/compta/bank/annuel.php | 6 +++--- htdocs/compta/bank/various_payment/list.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 197bbbc0c35..98085b34778 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -209,7 +209,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++) { $case = sprintf("%04s-%02s", $annee, $mois); - print ' '; + print ' '; if ($decaiss[$case]>0) { print price($decaiss[$case]); @@ -217,7 +217,7 @@ for ($mois = 1 ; $mois < 13 ; $mois++) } print ""; - print ' '; + print ' '; if ($encaiss[$case]>0) { print price($encaiss[$case]); @@ -266,7 +266,7 @@ else { print ''; print '"; -print ''; +print ''; print "\n"; print "
    '.$langs->trans("CurrentBalance")."'.price($balance).''.price($balance).'
    "; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 4437a9cfd2d..2d81facbad2 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -218,12 +218,12 @@ if ($result) } // Debit - print ''; + print ''; // Credit - print ''; + print ''; - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; @@ -238,8 +238,8 @@ if ($result) print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'align="left"', $sortfield, $sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); if (! empty($conf->accounting->enabled)) print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "v.accountancy_code", "", $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "v.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "v.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -328,8 +328,8 @@ if ($result) print ''; print ''.$langs->trans("Total").''; - print ''.price($totalarray['totaldeb']).""; - print ''.price($totalarray['totalcred']).""; + print ''.price($totalarray['totaldeb']).""; + print ''.price($totalarray['totalcred']).""; print ''; print ''; From 386a4102b71a7316902bca6dfed36b0c03b69cf6 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 13:44:02 +0100 Subject: [PATCH 09/77] update with html5 compliant code --- htdocs/compta/bank/bankentries_list.php | 28 ++++++++++++------------- htdocs/compta/bank/list.php | 4 ++-- htdocs/compta/bank/releve.php | 8 +++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 2b599b1e60d..edd0f35c442 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -666,10 +666,10 @@ if ($resql) print ''.$langs->trans("Numero").''; //if (! $search_account > 0) //{ - print ''.$langs->trans("BankAccount").''; + print ''.$langs->trans("BankAccount").''; //} - print ''.$langs->trans("Debit").''; - print ''.$langs->trans("Credit").''; + print ''.$langs->trans("Debit").''; + print ''.$langs->trans("Credit").''; /*if (! empty($conf->accounting->enabled)) { print ''; @@ -700,7 +700,7 @@ if ($resql) print ''; //if (! $search_account > 0) //{ - print ''; + print ''; $form->select_comptes(GETPOST('add_account', 'int')?GETPOST('add_account', 'int'):$search_account, 'add_account', 0, '', 1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); print ''; //} @@ -955,11 +955,11 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'], $_SERVER['PHP_SELF'], 'b.num_chq', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'], $_SERVER['PHP_SELF'], 'bu.label', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); - if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['balancebefore']['checked'])) print_liste_field_titre($arrayfields['balancebefore']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'], $_SERVER['PHP_SELF'], 'b.num_releve', '', $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['b.conciliated']['checked'])) print_liste_field_titre($arrayfields['b.conciliated']['label'], $_SERVER['PHP_SELF'], 'b.rappro', '', $param, 'align="center"', $sortfield, $sortorder); // Extra fields @@ -968,7 +968,7 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, 'maxwidthsearch '); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'class="right"', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -1355,7 +1355,7 @@ if ($resql) // Debit if (! empty($arrayfields['b.debit']['checked'])) { - print ''; + print ''; if ($objp->amount < 0) { print price($objp->amount * -1); @@ -1396,7 +1396,7 @@ if ($resql) } else { - print '-'; + print '-'; } if (! $i) $totalarray['nbfield']++; } @@ -1411,12 +1411,12 @@ if ($resql) } else { - print ' '.price($balance).''; + print ' '.price($balance).''; } } else { - print '-'; + print '-'; } if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 0333bfa52ed..6aac94532df 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -394,7 +394,7 @@ print $hookmanager->resPrint; if (! empty($arrayfields['b.datec']['checked'])) print_liste_field_titre($arrayfields['b.datec']['label'], $_SERVER["PHP_SELF"], "b.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['b.tms']['checked'])) print_liste_field_titre($arrayfields['b.tms']['label'], $_SERVER["PHP_SELF"], "b.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['b.clos']['checked'])) print_liste_field_titre($arrayfields['b.clos']['label'], $_SERVER["PHP_SELF"], 'b.clos', '', $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'align="right"', $sortfield, $sortorder); +if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -550,7 +550,7 @@ foreach ($accounts as $key=>$type) // Balance if (! empty($arrayfields['balance']['checked'])) { - print ''; + print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $obj->currency_code).''; print ''; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 140df3be2fd..6c6a8447c5a 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -766,15 +766,15 @@ else if ($objp->amount < 0) { $totald = $totald + abs($objp->amount); - print ''.price($objp->amount * -1)." \n"; + print ''.price($objp->amount * -1)." \n"; } else { $totalc = $totalc + abs($objp->amount); - print ' '.price($objp->amount)."\n"; + print ' '.price($objp->amount)."\n"; } - print ''.price(price2num($total, 'MT'))."\n"; + print ''.price(price2num($total, 'MT'))."\n"; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { @@ -793,7 +793,7 @@ else } // Line Total - print "\n".''.$langs->trans("Total")." :".price($totald)."".price($totalc)."  "; + print "\n".''.$langs->trans("Total")." :".price($totald)."".price($totalc)."  "; // Line Balance print "\n"; From 28a2135409c800a83c76bf5e67fd52b3503e98fc Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 13:45:50 +0100 Subject: [PATCH 10/77] update with html5 compliant code --- htdocs/compta/cashcontrol/cashcontrol_list.php | 2 +- htdocs/compta/cashcontrol/report.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 2db889e505d..89b66531eec 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -401,7 +401,7 @@ $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +print ''; $searchpicto=$form->showFilterButtons(); print $searchpicto; print ''; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 348c9bab450..736090bd07b 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -139,10 +139,10 @@ if ($resql) // Fields title print ''; print_liste_field_titre($arrayfields['b.rowid']['label'], $_SERVER['PHP_SELF'], 'b.rowid', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, 'align="left"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['b.dateo']['label'], $_SERVER['PHP_SELF'], 'b.dateo', '', $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['ba.ref']['label'], $_SERVER['PHP_SELF'], 'ba.ref', '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['b.debit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['b.credit']['label'], $_SERVER['PHP_SELF'], 'b.amount', '', $param, 'class="right"', $sortfield, $sortorder); print "\n"; $posconciliatecol = 0; From a14332b2b0d767523517eec37894b037e9622a56 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 4 Feb 2019 13:51:39 +0100 Subject: [PATCH 11/77] update with html5 compliant code --- htdocs/compta/charges/index.php | 10 +++--- htdocs/compta/deplacement/card.php | 2 +- htdocs/compta/deplacement/list.php | 6 ++-- htdocs/compta/facture/stats/index.php | 36 +++++++++---------- .../facture/tpl/linkedobjectblock.tpl.php | 12 +++---- .../tpl/linkedobjectblockForRec.tpl.php | 12 +++---- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index e2381605306..8ff14a88f79 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -123,12 +123,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; $sql = "SELECT c.id, c.libelle as lib,"; @@ -226,12 +226,12 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $i++; } print ''.$langs->trans("Total").''; - print ''; // A total here has no sense + print ''; // A total here has no sense print ' '; print ' '; print ' '; if (! empty($conf->banque->enabled)) print ''; - print ''.price($totalpaye).""; + print ''.price($totalpaye).""; print ""; } else @@ -283,7 +283,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; $var=1; while ($i < $num) diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 60eb007e26a..9602216b955 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -483,7 +483,7 @@ elseif ($id) print ''; if ($action != 'classify' && $user->rights->deplacement->creer) { - print 'id.'">'; + print 'id.'">'; print img_edit($langs->trans('SetProject'), 1); print ''; } diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 4fba1b25aee..9ad85788ca0 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -127,7 +127,7 @@ if ($resql) print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder); - print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder); print_liste_field_titre(''); print "\n"; @@ -150,10 +150,10 @@ if ($resql) print ''; print ''; print ''; - print ''; + print ''; // print ''; print ''; - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; print ''; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 31dcac4f340..5d8fee98676 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -284,12 +284,12 @@ print '
    '; print ''; print ''; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; print ''; $oldyear=0; @@ -302,23 +302,23 @@ foreach ($data as $val) print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; } print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; $oldyear=$year; } diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index bc23384fe92..d184fb58966 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -51,7 +51,7 @@ foreach($linkedObjectBlock as $key => $objectlink) - - - + + 1) - - - + + + $objectlink) - - - + + 1) - - - + + + Date: Mon, 4 Feb 2019 13:57:38 +0100 Subject: [PATCH 12/77] update with html5 compliant code --- htdocs/compta/facture/card.php | 146 ++++++++++++++++----------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 45c557f68c9..47ad635977e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3735,7 +3735,7 @@ elseif ($id > 0 || ! empty($ref)) print $langs->trans('DateInvoice'); print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) - print ''; + print ''; print '
    '.$langs->trans("Year").''.$langs->trans("NumberOfBills").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%'.$langs->trans("NumberOfBills").'%'.$langs->trans("AmountTotal").'%'.$langs->trans("AmountAverage").'%
    0?'&userid='.$userid:'').'">'.$oldyear.'000000
    0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'], 'MT'), 1).''.round($val['total_diff']).''.price(price2num($val['avg'], 'MT'), 1).''.round($val['avg_diff']).''.$val['nb'].''.round($val['nb_diff']).''.price(price2num($val['total'], 'MT'), 1).''.round($val['total_diff']).''.price(price2num($val['avg'], 'MT'), 1).''.round($val['avg_diff']).'
    getNomUrl(1); ?> ref_client; ?> date, 'day'); ?>rights->facture->lire) { $sign = 1; if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; @@ -65,8 +65,8 @@ foreach($linkedObjectBlock as $key => $objectlink) echo ''.price($objectlink->total_ht).''; } } ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
    getNomUrl(1); ?> date_when, 'day'); ?>rights->facture->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
    id . '">' . img_edit($langs->trans('SetDate'), 1) . 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
    '; print ''; @@ -3759,7 +3759,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; - print ''; + print ''; print '
    '; print $langs->trans('DatePointOfTax'); print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
    '; print ''; if ($action == 'editdate_pointoftax') { @@ -3776,7 +3776,7 @@ elseif ($id > 0 || ! empty($ref)) print $langs->trans('PaymentConditionsShort'); print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; print ''; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -3797,7 +3797,7 @@ elseif ($id > 0 || ! empty($ref)) print $langs->trans('DateMaxPayment'); print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; print ''; print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE) @@ -3821,7 +3821,7 @@ elseif ($id > 0 || ! empty($ref)) print $langs->trans('PaymentMode'); print ''; if ($action != 'editmode' && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . ''; print ''; print ''; if ($action == 'editmode') @@ -3844,7 +3844,7 @@ elseif ($id > 0 || ! empty($ref)) print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($usercancreate && $action != 'editmulticurrencycode' && ! empty($object->brouillon)) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; print ''; $htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none'); @@ -3857,7 +3857,7 @@ elseif ($id > 0 || ! empty($ref)) print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -3882,7 +3882,7 @@ elseif ($id > 0 || ! empty($ref)) print $langs->trans('BankAccount'); print ''; if (($action != 'editbankaccount') && $usercancreate) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; print ''; print ''; if ($action == 'editbankaccount') @@ -3902,7 +3902,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; print '
    '; print $langs->trans('IncotermLabel'); - print ''; + print ''; if ($usercancreate) print ''.img_edit().''; else print ' '; print '
    '; @@ -3979,7 +3979,7 @@ elseif ($id > 0 || ! empty($ref)) print ''; if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $usercancreate) { - print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . ''; } print ''; print ''; @@ -4062,9 +4062,9 @@ elseif ($id > 0 || ! empty($ref)) print '' . $langs->trans('ListOfSituationInvoices') . ''; print ''; print '' . $langs->trans('Situation') . ''; - if (! empty($conf->banque->enabled)) print ''; - print '' . $langs->trans('AmountHT') . ''; - print '' . $langs->trans('AmountTTC') . ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . $langs->trans('AmountHT') . ''; + print '' . $langs->trans('AmountTTC') . ''; print ' '; print ''; @@ -4085,10 +4085,10 @@ elseif ($id > 0 || ! empty($ref)) print '' . $prev_invoice->getNomUrl(1) . ''; print ''; print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $prev_invoice->situation_counter.''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($prev_invoice->total_ht) . ''; - print '' . price($prev_invoice->total_ttc) . ''; - print '' . $prev_invoice->getLibStatut(3, $totalpaye) . ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($prev_invoice->total_ht) . ''; + print '' . price($prev_invoice->total_ttc) . ''; + print '' . $prev_invoice->getLibStatut(3, $totalpaye) . ''; print ''; } } @@ -4103,15 +4103,15 @@ elseif ($id > 0 || ! empty($ref)) print '' . $object->getNomUrl(1) . ''; print ''; print ''.(($object->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $object->situation_counter.''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($object->total_ht) . ''; - print '' . price($object->total_ttc) . ''; - print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($object->total_ht) . ''; + print '' . price($object->total_ttc) . ''; + print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ''; print ''; print ''; - print '' . $langs->trans('CurrentSituationTotal') . ''; + print '' . $langs->trans('CurrentSituationTotal') . ''; print ''; $i =0; foreach ($current_situation_counter as $sit) @@ -4124,8 +4124,8 @@ elseif ($id > 0 || ! empty($ref)) } print ''; if (! empty($conf->banque->enabled)) print ''; - print '' . price($total_global_ht) . ''; - print '' . price($total_global_ttc) . ''; + print '' . price($total_global_ht) . ''; + print '' . price($total_global_ttc) . ''; print ' '; print ''; @@ -4136,9 +4136,9 @@ elseif ($id > 0 || ! empty($ref)) print '' . $langs->trans('ListOfNextSituationInvoices') . ''; print ''; print ''; - if (! empty($conf->banque->enabled)) print ''; - print '' . $langs->trans('AmountHT') . ''; - print '' . $langs->trans('AmountTTC') . ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . $langs->trans('AmountHT') . ''; + print '' . $langs->trans('AmountTTC') . ''; print ' '; print '';*/ @@ -4153,10 +4153,10 @@ elseif ($id > 0 || ! empty($ref)) print '' . $next_invoice->getNomUrl(1) . ''; print ''; print ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE)?$langs->trans('situationInvoiceShortcode_AS'):$langs->trans('situationInvoiceShortcode_S')) . $next_invoice->situation_counter.''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($next_invoice->total_ht) . ''; - print '' . price($next_invoice->total_ttc) . ''; - print '' . $next_invoice->getLibStatut(3, $totalpaye) . ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($next_invoice->total_ht) . ''; + print '' . price($next_invoice->total_ttc) . ''; + print '' . $next_invoice->getLibStatut(3, $totalpaye) . ''; print ''; } @@ -4164,10 +4164,10 @@ elseif ($id > 0 || ! empty($ref)) $total_global_ttc += $total_next_ttc; print ''; - print ''; - if (! empty($conf->banque->enabled)) print ''; - print '' . price($total_global_ht) . ''; - print '' . price($total_global_ttc) . ''; + print ''; + if (! empty($conf->banque->enabled)) print ''; + print '' . price($total_global_ht) . ''; + print '' . price($total_global_ttc) . ''; print ' '; print ''; } @@ -4186,9 +4186,9 @@ elseif ($id > 0 || ! empty($ref)) print '' . $langs->trans('Date') . ''; print '' . $langs->trans('Type') . ''; if (! empty($conf->banque->enabled)) { - print '' . $langs->trans('BankAccount') . ''; + print '' . $langs->trans('BankAccount') . ''; } - print '' . $langs->trans('Amount') . ''; + print '' . $langs->trans('Amount') . ''; print ' '; print ''; @@ -4243,12 +4243,12 @@ elseif ($id > 0 || ! empty($ref)) $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); } - print ''; + print ''; if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1, 'transactions'); print ''; } - print '' . price($sign * $objp->amount) . ''; + print '' . price($sign * $objp->amount) . ''; print ''; if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->societe_id == 0) { @@ -4272,12 +4272,12 @@ elseif ($id > 0 || ! empty($ref)) if ($object->type != Facture::TYPE_CREDIT_NOTE) { // Total already paid - print ''; + print ''; if ($object->type != Facture::TYPE_DEPOSIT) print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); else print $langs->trans('AlreadyPaid'); - print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' '; + print ' : 0)?' class="amountalreadypaid"':'').'>' . price($totalpaye) . ' '; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -4297,15 +4297,15 @@ elseif ($id > 0 || ! empty($ref)) while ($i < $num) { $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_facture_source); - print ''; + print ''; if ($invoice->type == Facture::TYPE_CREDIT_NOTE) print $langs->trans("CreditNote") . ' '; if ($invoice->type == Facture::TYPE_DEPOSIT) print $langs->trans("Deposit") . ' '; print $invoice->getNomUrl(0); print ' :'; - print '' . price($obj->amount_ttc) . ''; - print ''; + print '' . price($obj->amount_ttc) . ''; + print ''; print 'rowid . '">' . img_delete() . ''; print ''; $i ++; @@ -4320,51 +4320,51 @@ elseif ($id > 0 || ! empty($ref)) // Paye partiellement 'escompte' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { - print ''; + print ''; print $form->textwithpicto($langs->trans("Discount") . ':', $langs->trans("HelpEscompte"), - 1); - print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; + print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'badcustomer' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') { - print ''; + print ''; print $form->textwithpicto($langs->trans("Abandoned") . ':', $langs->trans("HelpAbandonBadCustomer"), - 1); - print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; + print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'product_returned' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') { - print ''; + print ''; print $form->textwithpicto($langs->trans("ProductReturned") . ':', $langs->trans("HelpAbandonProductReturned"), - 1); - print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; + print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Paye partiellement ou Abandon 'abandon' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'abandon') { - print ''; + print ''; $text = $langs->trans("HelpAbandonOther"); if ($object->close_note) $text .= '

    ' . $langs->trans("Reason") . ':' . $object->close_note; print $form->textwithpicto($langs->trans("Abandoned") . ':', $text, - 1); - print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; + print '' . price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')) . ' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Billed - print '' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' '; + print '' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' '; // Remainder to pay - print ''; + print ''; if ($resteapayeraffiche >= 0) print $langs->trans('RemainderToPay'); else print $langs->trans('ExcessReceived'); print ' :'; - print '' . price($resteapayeraffiche) . ''; + print '' . price($resteapayeraffiche) . ''; print ' '; } else // Credit note @@ -4372,26 +4372,26 @@ elseif ($id > 0 || ! empty($ref)) $cssforamountpaymentcomplete='amountpaymentneutral'; // Total already paid back - print ''; + print ''; print $langs->trans('AlreadyPaidBack'); - print ' :' . price($sign * $totalpaye) . ' '; + print ' :' . price($sign * $totalpaye) . ' '; // Billed - print '' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' '; + print '' . $langs->trans("Billed") . ' :' . price($sign * $object->total_ttc) . ' '; // Remainder to pay back - print ''; + print ''; if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack'); else print $langs->trans('ExcessPaid'); print ' :'; - print '' . price($sign * $resteapayeraffiche) . ''; + print '' . price($sign * $resteapayeraffiche) . ''; print ' '; // Sold credit note - // print ''.$langs->trans('TotalTTC').' :'; - // print ''.price($sign * + // print ''.$langs->trans('TotalTTC').' :'; + // print ''.price($sign * // $object->total_ttc).' '; } @@ -4444,20 +4444,20 @@ elseif ($id > 0 || ! empty($ref)) print ' '; } print '' . $langs->trans('ModifyAllLines') . ''; - print ' '; - print ' '; - if ($inputalsopricewithtax) print ' '; - print ' '; - print ' '; - print '' . $langs->trans('Progress') . ''; + print ' '; + print ' '; + if ($inputalsopricewithtax) print ' '; + print ' '; + print ' '; + print '' . $langs->trans('Progress') . ''; if (! empty($conf->margin->enabled) && empty($user->societe_id)) { - print ' '; + print ' '; if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $usercanreadallmargin) { - print ' '; + print ' '; } } - print ' '; + print ' '; print ' '; print ' '; print ' '; @@ -4473,8 +4473,8 @@ elseif ($id > 0 || ! empty($ref)) print ' '; print ' '; print ' '; - print '%'; - print ''; + print '%'; + print ''; print ''; print ''; From 4a19cba257b20552b0e41849b323e09fd0f7b110 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 5 Feb 2019 06:34:05 +0100 Subject: [PATCH 13/77] FIX [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4881e42abf1..73b2bfdb314 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4551,7 +4551,7 @@ else if ($id > 0 || ! empty($ref)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') + if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { if ($action != 'editline' && $action != 'selectlines') { From 8860eab6b11e449ae1394ae2315690876668aad1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 5 Feb 2019 07:40:50 +0100 Subject: [PATCH 14/77] FIX wrong merged conflict --- htdocs/compta/facture/card.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9f2de6d3eb9..2df6e96e7c2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4594,7 +4594,7 @@ else if ($id > 0 || ! empty($ref)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline' && ($object->is_first() || empty($object->situation_cycle_ref))) + if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') { if ($action != 'editline' && $action != 'selectlines') { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 73ee29373f6..a593e70a7f6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5907,10 +5907,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); // For backward compatibility $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); - $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); // TODO Remove this $msgishtml = 0; From 730a2a90fffb43bf47acd605a3ac4e584608a3a8 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 5 Feb 2019 09:43:14 +0100 Subject: [PATCH 15/77] FIX supplier invoice product stats total ht is line total not invoice total --- htdocs/product/stats/facture_fournisseur.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 6bd722220ba..a31d94ada69 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -126,7 +126,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->fournisseur->facture->lire) { - $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as total_ht,"; + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -205,7 +205,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -215,7 +215,7 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->total_ht; + $total_ht+=$objp->line_total_ht; $total_qty+=$objp->qty; $supplierinvoicestatic->id = $objp->facid; @@ -237,7 +237,7 @@ if ($id > 0 || ! empty($ref)) print ''; print dol_print_date($db->jdate($objp->datef), 'dayhour') . ""; print '' . $objp->qty . "\n"; - print '' . price($objp->total_ht) . "\n"; + print '' . price($objp->line_total_ht) . "\n"; print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''; print "\n"; $i++; From da0c863f459387d0f2dcbd7d79a3f62c70d002f6 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 5 Feb 2019 10:30:38 +0100 Subject: [PATCH 16/77] FIX supplier invoice payment total dont care about deposit or credit --- htdocs/fourn/facture/paiement.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 74593cb8675..8a87d4903a1 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -602,7 +602,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.price($objp->total_ttc).''; - print ''.price($objp->am).''; + print ''.price($objp->am); + if ($creditnotes) print '+'.price($creditnotes); + if ($deposits) print '+'.price($deposits); + print ''; print ''.price($remaintopay).''; @@ -657,6 +660,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $total+=$objp->total_ht; $total_ttc+=$objp->total_ttc; $totalrecu+=$objp->am; + $totalrecucreditnote+=$creditnotes; + $totalrecudeposits+=$deposits; $i++; } if ($i > 1) @@ -669,8 +674,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ' '; if (!empty($conf->multicurrency->enabled)) print ' '; print ''.price($total_ttc).''; - print ''.price($totalrecu).''; - print ''.price($total_ttc - $totalrecu).''; + print ''.price($totalrecu); + if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); + if ($totalrecudeposits) print '+'.price($totalrecudeposits); + print ''; + print ''.price(price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).''; print ''; // Autofilled if (!empty($conf->multicurrency->enabled)) print ''; print "\n"; From 64739098ae31d8277a145784fa45863f7f65baf7 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 5 Feb 2019 11:58:49 +0100 Subject: [PATCH 17/77] FIX: expedition: reset status on rollback + replace hardcoded status with const --- htdocs/expedition/class/expedition.class.php | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b4e4e0c8614..d7960d6ff52 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -538,7 +538,7 @@ class Expedition extends CommonObject $this->db->free($result); - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; // Tracking url $this->GetUrlTrackingStatus($obj->tracking_number); @@ -783,7 +783,7 @@ class Expedition extends CommonObject if (! $error) { $this->ref = $numref; - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; } if (! $error) @@ -816,7 +816,7 @@ class Expedition extends CommonObject if ($conf->livraison_bon->enabled) { - if ($this->statut == 1 || $this->statut == 2) + if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) { // Expedition validee include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; @@ -1111,7 +1111,7 @@ class Expedition extends CommonObject $this->db->begin(); // Stock control - if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) + if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); @@ -1663,7 +1663,7 @@ class Expedition extends CommonObject $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; $this->livraison_id = 0; $this->date = $now; $this->date_creation = $now; @@ -2037,6 +2037,7 @@ class Expedition extends CommonObject } else { + $this->statut = self::STATUS_VALIDATED; $this->db->rollback(); return -1; } @@ -2060,7 +2061,7 @@ class Expedition extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->statut=2; + $this->statut=self::STATUS_CLOSED; $this->billed=1; // Call trigger @@ -2080,6 +2081,8 @@ class Expedition extends CommonObject } else { + $this->statut=self::STATUS_VALIDATED; + $this->billed=0; $this->db->rollback(); return -1; } @@ -2104,13 +2107,15 @@ class Expedition extends CommonObject $this->db->begin(); + $oldbilled=$this->billed; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $resql=$this->db->query($sql); if ($resql) { - $this->statut=1; + $this->statut=self::STATUS_VALIDATED; $this->billed=0; // If stock increment is done on closing @@ -2208,6 +2213,8 @@ class Expedition extends CommonObject } else { + $this->statut=self::STATUS_CLOSED; + $this->billed=$oldbilled; $this->db->rollback(); return -1; } From 428efa922797502740342eac001a70e53a20c5db Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 5 Feb 2019 12:02:49 +0100 Subject: [PATCH 18/77] FIX: line edit template: keep fk_parent_line --- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 41d419694e8..b5d2f035695 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -69,9 +69,13 @@ $coldisplay=-1; // We remove first td + fk_product > 0) { ?> + fk_parent_line > 0) echo img_picto('', 'rightarrow'); + ?> product_type==1) echo img_object($langs->trans('ShowService'),'service'); From bb315a6f12da1906306c9fbf1c1a23b0d39368c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 16:44:10 +0100 Subject: [PATCH 19/77] Fix trans --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 95b93aba4e9..2aff094b4c0 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -147,7 +147,7 @@ CloneProduct=Clone product or service ConfirmCloneProduct=Are you sure you want to clone product or service %s? CloneContentProduct=Clone all main information of product/service ClonePricesProduct=Clone prices -CloneCompositionProduct=Clone packaged product/service +CloneCompositionProduct=Clone virtual product/service CloneCombinationsProduct=Clone product variants ProductIsUsed=This product is used NewRefForClone=Ref. of new product/service From f4c5f1e3f1e5ab4104eca7409c7bb82952bf1a56 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Tue, 5 Feb 2019 17:02:43 +0100 Subject: [PATCH 20/77] Revert "Fix filter by event type Emailing in show actions done (companylib)" This reverts commit 225e69a4de04b4c8b825165b00449e97854d7177. --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2d0b08b22d4..8b8bfb923f0 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1469,7 +1469,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } // Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing. - if (! empty($conf->mailing->enabled) && ! empty($objcon->email) && (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING')) + if (! empty($conf->mailing->enabled) && ! empty($objcon->email)) { $langs->load("mails"); From 727213a5fdc28704505a5ca58f6f8d8797b20fea Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Tue, 5 Feb 2019 17:04:46 +0100 Subject: [PATCH 21/77] Fix margin by users when a thirdparty have many sellers --- htdocs/margin/agentMargins.php | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index d42a2b8d6e3..a8cd77b846f 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -126,7 +126,8 @@ dol_fiche_end(); print ''; $sql = "SELECT"; -if ($agentid > 0) $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,"; +$sql.= " s.rowid as socid,"; +if ($agentid > 0) $sql.= " s.nom as name, s.code_client, s.client,"; $sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,"; $sql.= " sum(d.total_ht) as selling_price,"; // Note: qty and buy_price_ht is always positive (if not your database may be corrupted, you can update this) @@ -213,9 +214,29 @@ if ($result) { $objp = $db->fetch_object($result); - $pa = $objp->buying_price; - $pv = $objp->selling_price; - $marge = $objp->marge; + $seller_nb = 1; + if ($objp->socid > 0) { + // sql nb sellers + $sql_seller = "SELECT COUNT(sc.rowid) as nb"; + $sql_seller .= " FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql_seller .= " WHERE sc.fk_soc = " . $objp->socid; + $sql_seller .= " LIMIT 1"; + + $resql_seller = $db->query($sql_seller); + if (!$resql_seller) { + dol_print_error($db); + } else { + if ($obj_seller = $db->fetch_object($resql_seller)) { + if ($obj_seller->nb > 0) { + $seller_nb = $obj_seller->nb; + } + } + } + } + + $pa = $objp->buying_price / $seller_nb; + $pv = $objp->selling_price / $seller_nb; + $marge = $objp->marge / $seller_nb; if ($marge < 0) { From 44f5223c90325c330182e12800598e553da4a221 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 18:54:38 +0100 Subject: [PATCH 22/77] Remove warning --- htdocs/admin/tools/export.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 6b0ea790ab2..5bfacc6c4f0 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -35,14 +35,15 @@ $what=GETPOST('what','alpha'); $export_type=GETPOST('export_type','alpha'); $file=GETPOST('filename_template','alpha'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST("page",'int'); +if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; -if ($page < 0) { $page = 0; } -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page; if (! $user->admin) accessforbidden(); From 66998c4873b165a08edc8bf1f84c9b75c62d82ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:37:22 +0100 Subject: [PATCH 23/77] Fix translation --- htdocs/langs/en_US/members.lang | 3 ++- htdocs/langs/fr_FR/members.lang | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 6bee353c7ea..35e5a4b35f6 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -195,4 +195,5 @@ NoEmailSentToMember=No email sent to member EmailSentToMember=Email sent to member at %s SendReminderForExpiredSubscriptionTitle=Send reminder by email for expired subscription SendReminderForExpiredSubscription=Send reminder by email to members when subscription is about to expire (parameter is number of days before end of subscription to send the remind. It can be a list of days separated by a semicolon, for example '10;5;0;-5') -MembershipPaid=Membership paid for current period (until %s) \ No newline at end of file +MembershipPaid=Membership paid for current period (until %s) +YouMayFindYourInvoceInThisEmail=You may find your invoice attached to this email \ No newline at end of file diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 183b11d7e81..0e6ca75ace0 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -195,3 +195,4 @@ NoEmailSentToMember=Aucun e-mail envoyé à l'adhérent EmailSentToMember=Email envoyé à l'adhérent à %s SendReminderForExpiredSubscriptionTitle=Envoyer une relance par mail pour les cotisations expirées SendReminderForExpiredSubscription=Envoyer un rappel par e-mail aux membres lorsque l'adhésion est sur le point d'expirer (le paramètre est le nombre de jours avant la fin de l'adhésion pour envoyer le rappel. Il peut s'agir d'une liste de jours séparé par un point-virgule, par exemple '10;5;0;-5') +YouMayFindYourInvoceInThisEmail=You pourrez trouver votre facture en pièce jointe à cet email \ No newline at end of file From 7436a3bc73d53e74c5eb509bb2d63c4e9ac32d85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:37:58 +0100 Subject: [PATCH 24/77] Typo --- htdocs/langs/en_US/members.lang | 2 +- htdocs/langs/fr_FR/members.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 35e5a4b35f6..6de01d396dc 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -196,4 +196,4 @@ EmailSentToMember=Email sent to member at %s SendReminderForExpiredSubscriptionTitle=Send reminder by email for expired subscription SendReminderForExpiredSubscription=Send reminder by email to members when subscription is about to expire (parameter is number of days before end of subscription to send the remind. It can be a list of days separated by a semicolon, for example '10;5;0;-5') MembershipPaid=Membership paid for current period (until %s) -YouMayFindYourInvoceInThisEmail=You may find your invoice attached to this email \ No newline at end of file +YouMayFindYourInvoiceInThisEmail=You may find your invoice attached to this email \ No newline at end of file diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 0e6ca75ace0..0bc9b0c80b2 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -195,4 +195,4 @@ NoEmailSentToMember=Aucun e-mail envoyé à l'adhérent EmailSentToMember=Email envoyé à l'adhérent à %s SendReminderForExpiredSubscriptionTitle=Envoyer une relance par mail pour les cotisations expirées SendReminderForExpiredSubscription=Envoyer un rappel par e-mail aux membres lorsque l'adhésion est sur le point d'expirer (le paramètre est le nombre de jours avant la fin de l'adhésion pour envoyer le rappel. Il peut s'agir d'une liste de jours séparé par un point-virgule, par exemple '10;5;0;-5') -YouMayFindYourInvoceInThisEmail=You pourrez trouver votre facture en pièce jointe à cet email \ No newline at end of file +YouMayFindYourInvoiceInThisEmail=You pourrez trouver votre facture en pièce jointe à cet email \ No newline at end of file From 7c24847fa3b3329de4075ae213290a179f5e25ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:38:28 +0100 Subject: [PATCH 25/77] Typo --- htdocs/langs/en_US/members.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 6de01d396dc..588941d30f9 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -187,7 +187,7 @@ MembersStatisticsByProperties=Members statistics by nature MembersByNature=This screen show you statistics on members by nature. MembersByRegion=This screen show you statistics on members by region. VATToUseForSubscriptions=VAT rate to use for subscriptions -NoVatOnSubscription=No TVA for subscriptions +NoVatOnSubscription=No VAT for subscriptions ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS=Product used for subscription line into invoice: %s NameOrCompany=Name or company SubscriptionRecorded=Subscription recorded From 5a659bfd9008628c7dc1571166d58844c6e69577 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:57:35 +0100 Subject: [PATCH 26/77] Fix Missing currency --- htdocs/adherents/subscription.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index b66e472fabf..ae412d59c66 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -673,7 +673,7 @@ if ($rowid > 0) $sql.= " c.datef,"; $sql.= " c.fk_bank,"; $sql.= " b.rowid as bid,"; - $sql.= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number"; + $sql.= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; @@ -726,8 +726,9 @@ if ($rowid > 0) $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; + $accountstatic->country_code=$obj->currency_code; - if (! empty($conf->accounting->enabled)) + if (! empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objp->fk_accountancy_journal); From d4e6610722c1fc2c731647bcc6f1430f49fcec34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:58:42 +0100 Subject: [PATCH 27/77] Fix currency --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index ae412d59c66..c6215717f9a 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -726,7 +726,7 @@ if ($rowid > 0) $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; - $accountstatic->country_code=$obj->currency_code; + $accountstatic->currency_code=$obj->currency_code; if (! empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) { From 27f804a454f3670d8f9093f35fc48c0179b05946 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 19:59:36 +0100 Subject: [PATCH 28/77] Fix currency --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index c6215717f9a..2b8684793c2 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -726,7 +726,7 @@ if ($rowid > 0) $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; - $accountstatic->currency_code=$obj->currency_code; + $accountstatic->currency_code=$objp->currency_code; if (! empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) { From 82df83cec2a5b13e3ebebe33d7cff334274c8e17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 20:04:25 +0100 Subject: [PATCH 29/77] Add log --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ea624209f3e..4cfb47947c2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2760,7 +2760,7 @@ class Adherent extends CommonObject $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language set to ".$outputlangs->defaultlang); + dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang); $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; From db50ef39e7762dddcb4f594b7dfecb09d5d49f28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 20:32:14 +0100 Subject: [PATCH 30/77] FIX Translation not loaded by scheduled jobs --- scripts/cron/cron_run_jobs.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 873fc0ae9fb..a3b7d83684d 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -65,10 +65,13 @@ $version=DOL_VERSION; $error=0; + /* * Main */ +$langs->loadLangs(array('main', 'dict')); + // current date $now=dol_now(); From ce5717a7b748306bf7d76f668cb34a6fe53b0183 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Feb 2019 20:43:26 +0100 Subject: [PATCH 31/77] FIX Default language of company is not set --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/societe/class/societe.class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4cfb47947c2..7872ed1ca68 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2760,7 +2760,7 @@ class Adherent extends CommonObject $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); $outputlangs->loadLangs(array("main", "members")); - dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang); + dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a22293f60e6..ca074c87070 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3439,6 +3439,7 @@ class Societe extends CommonObject $this->capital=empty($conf->global->MAIN_INFO_CAPITAL)?'':$conf->global->MAIN_INFO_CAPITAL; $this->forme_juridique_code=empty($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE)?'':$conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE; $this->email=empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?'':$conf->global->MAIN_INFO_SOCIETE_MAIL; + $this->default_lang = (empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT); $this->logo=empty($conf->global->MAIN_INFO_SOCIETE_LOGO)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO; $this->logo_small=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_SMALL; $this->logo_mini=empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; From 7c82b416ae6d705e33040c58b28ff69086ea90f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Feb 2019 20:56:34 +0100 Subject: [PATCH 32/77] fix phpcs public/payment/newpayment.php --- htdocs/public/payment/newpayment.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 6113f5aa91e..3da91bac61c 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1319,10 +1319,9 @@ if ($source == 'membersubscription') print ''; print ''."\n"; - if ($object->datefin > 0) - { + if ($object->datefin > 0) { print ''.$langs->trans("DateEndSubscription"); - print ''.dol_print_date($member->datefin,'day'); + print ''.dol_print_date($member->datefin, 'day'); print ''."\n"; } From 7b8464c65df8209ebb414221ed94cff8e21ce8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Feb 2019 21:16:48 +0100 Subject: [PATCH 33/77] .editorconfig for php psr2 --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index a40a586406f..3c4bd7d679d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,8 +7,12 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true + +# PHP PSR-2 Coding Standards +# http://www.php-fig.org/psr/psr-2/ [*.php] indent_style = space +indent_size = 4 trim_trailing_whitespace = true [*.js] indent_style = tab From 58e6cfd635fd2363a879137359981ee3c08d6b91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Feb 2019 00:36:11 +0100 Subject: [PATCH 34/77] Fix popup content --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2eafaa2c2ea..567917aa352 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1291,7 +1291,7 @@ class ActionComm extends CommonObject if (! empty($this->location)) $tooltip .= '
    ' . $langs->trans('Location') . ': ' . $this->location; if (! empty($this->note)) - $tooltip .= '
    ' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : $this->note); + $tooltip .= '
    ' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : str_replace(array('\r','\n'), '
    ', $this->note)); $linkclose=''; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; From 88fb4914418ebe66a7e75e6b04473ed020cd265b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Feb 2019 00:40:07 +0100 Subject: [PATCH 35/77] Fix note output --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 567917aa352..4ac6579592e 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1291,7 +1291,7 @@ class ActionComm extends CommonObject if (! empty($this->location)) $tooltip .= '
    ' . $langs->trans('Location') . ': ' . $this->location; if (! empty($this->note)) - $tooltip .= '
    ' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : str_replace(array('\r','\n'), '
    ', $this->note)); + $tooltip .= '
    ' . $langs->trans('Note') . ': ' . (dol_textishtml($this->note) ? str_replace(array("\r","\n"), "", $this->note) : str_replace(array("\r","\n"), '
    ', $this->note)); $linkclose=''; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) $linkclose = ' style="background-color:#'.$this->type_color.'"'; From 58eaee2acf7942831861fc5c1989c498200e8aa6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Feb 2019 00:56:28 +0100 Subject: [PATCH 36/77] Fix css --- htdocs/cron/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 420d295bd55..11d2b3acd35 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -446,7 +446,7 @@ if ($num > 0) print ''; // Ref - print ''; + print ''; print $object->getNomUrl(1); print ''; From 95cc9faf7e0978228627a6331b78db1e9e0cd65b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 09:01:24 +0100 Subject: [PATCH 37/77] fix php warning --- htdocs/core/class/commondocgenerator.class.php | 12 ++++++++---- htdocs/imports/import.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 18e2817f040..214c47fc20d 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -340,6 +340,8 @@ abstract class CommonDocGenerator global $conf; $sumpayed=$sumdeposit=$sumcreditnote=''; + $already_payed_all=0; + $remain_to_pay=0; if ($object->element == 'facture') { $invoice_source=new Facture($this->db); @@ -350,6 +352,8 @@ abstract class CommonDocGenerator $sumpayed = $object->getSommePaiement(); $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); + $already_payed_all=$sumpayed + $sumdeposit + $sumcreditnote; + $remain_to_pay=$sumpayed - $sumdeposit - $sumcreditnote; } $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); @@ -411,12 +415,12 @@ abstract class CommonDocGenerator $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), // Remain to pay with all know infrmation (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') ); if (method_exists($object, 'getTotalDiscount')) { diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index c57a4207782..b1caff18022 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1332,7 +1332,7 @@ if ($step == 5 && $datatoimport) } print '  
    '.$langs->trans("Modify").''; } else { - if (count($objimport->array_import_updatekeys[0])) + if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0])) { print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%'); print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); From b87df1829258761c62d0933a75ee41f8c33e51e3 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Wed, 6 Feb 2019 09:37:19 +0100 Subject: [PATCH 38/77] Fix the margin rate by seller when the margin is negative --- htdocs/margin/agentMargins.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index a8cd77b846f..0ad6563767c 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -238,16 +238,8 @@ if ($result) $pv = $objp->selling_price / $seller_nb; $marge = $objp->marge / $seller_nb; - if ($marge < 0) - { - $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; - $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; - } - else - { - $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; - $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; - } + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; print ''; if ($agentid > 0) { From 3f20cae6d349acf7769f0976b29e3f7e2f1ab44a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:54:11 +0100 Subject: [PATCH 39/77] NEW: setup default thridparty type (customer or prospect/customer) --- htdocs/core/class/html.formcompany.class.php | 40 +++++++++++++ htdocs/langs/en_US/admin.lang | 3 +- htdocs/societe/admin/societe.php | 63 ++++++++------------ htdocs/societe/card.php | 26 ++++---- htdocs/societe/list.php | 5 +- 5 files changed, 83 insertions(+), 54 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 58c9950898c..d28b867dc93 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -888,4 +888,44 @@ class FormCompany } } } + + function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname='customerprospect', $typeinput='form',$morecss = '') { + + global $conf,$langs; + + $out = ''; + + return $out; + } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d92a0b47bcc..99b92e67074 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1854,4 +1854,5 @@ OnMobileOnly=On small screen (smartphone) only DisableProspectCustomerType=Disable the "Prospect + Customer" third party type (so third party must be Prospect or Customer but can't be both) MAIN_OPTIMIZEFORTEXTBROWSER=Simplify interface for blind person MAIN_OPTIMIZEFORTEXTBROWSERDesc=Enable this option if you are a blind person, or if you use the application from a text browser like Lynx or Links. -ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s' \ No newline at end of file +ThisValueCanOverwrittenOnUserLevel=This value can be overwritten by each user from its user page - tab '%s' +DefaultCustomerType=Default thirdparty type for "New customer" creation form \ No newline at end of file diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 6f808b8307a..e283d3220b2 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array("admin", "companies", "other")); @@ -36,6 +37,8 @@ $value=GETPOST('value', 'alpha'); if (!$user->admin) accessforbidden(); +$formcompany = new FormCompany($db); + /* @@ -101,6 +104,21 @@ if ($action == 'updateoptions') setEventMessages($langs->trans("Error"), null, 'errors'); } } + + if (GETPOST('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) + { + $customertypedefault = GETPOST('defaultcustomertype', 'int'); + $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } // Activate a document generator module @@ -306,7 +324,6 @@ if($action=='setonsearchandlistgooncustomerorsuppliercard'){ } } - /* * View */ @@ -861,44 +878,16 @@ else print ''; print ''; -/*print ''; -print ''.$langs->trans("OnSearchAndListGoOnCustomerOrSupplierCard").''; -print ' '; -print ''; -if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) -{ - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); -} -print ''; -print ''; -*/ - -/* -// COMPANY_USE_SEARCH_TO_SELECT - +// Default Prospect/Customer thirdparty type on customer création print ''; -print ''.$langs->trans("HideClosedThirdpartyComboBox").''; -if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) -{ - print ''; - print img_picto($langs->trans("Activated"),'switch_on'); - print ''; -} -else -{ - print ''; - print img_picto($langs->trans("Disabled"),'switch_off'); - print ''; -} +print ''.$langs->trans("DefaultCustomerType").''; +print ''; +print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT,'defaultcustomertype','defaultcustomertype','admin'); +print ''; +print ''; +print ''; +print ''; print ''; -*/ print ''; print '
    '; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index bde8dffbb8f..d1ac49813f7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -937,7 +937,13 @@ else $object->client=-1; if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } } - if (GETPOST("type")=='c') { $object->client=3; } // Prospect / Customer + if (GETPOST("type")=='c') { + if (! empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { + $object->client=$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; + } else { + $object->client=3; + } + } if (GETPOST("type")=='p') { $object->client=2; } if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; } @@ -1179,13 +1185,8 @@ else print ''.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; print ''; $selected=GETPOST('client', 'int')!=''?GETPOST('client', 'int'):$object->client; - print ''; + print $formcompany->selectProspectCustomerType($selected,'client'); + print ''; print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; print ''; - print ''; + print ''; print '
    '; @@ -1770,12 +1771,9 @@ else // Prospect/Customer print '
    '.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; + print $formcompany->selectProspectCustomerType($object->client,'client'); + print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; print ''; } // Prospect level From 813a7a008511d9ac3c146b5beda6dde25397867d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:57:11 +0100 Subject: [PATCH 40/77] remove comment --- htdocs/societe/list.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 23e40ccc317..9258cd56ba6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -832,13 +832,6 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) print ''; } // Prospect level From 3f6187fe120b477738690c631023adb49319ea5d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:58:40 +0100 Subject: [PATCH 41/77] remove useless parameters --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index d1ac49813f7..a2c2acdd9a7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1185,7 +1185,7 @@ else print ''; print ''; print ''; print ''; print ''; } +if (! empty($arrayfields['s.fk_parent']['checked'])) +{ + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -929,6 +941,7 @@ if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titr if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['s.fk_parent']['checked'])) print_liste_field_titre($arrayfields['s.fk_parent']['label'], $_SERVER["PHP_SELF"], "s.parent", "", $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -965,6 +978,7 @@ while ($i < min($num, $limit)) $companystatic->code_compta_fournisseur=$obj->code_compta_fournisseur; $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; + $companystatic->fk_parent = $obj->fk_parent; print ''; if (! empty($arrayfields['s.rowid']['checked'])) @@ -1181,6 +1195,18 @@ while ($i < min($num, $limit)) print ''; if (! $i) $totalarray['nbfield']++; } + // Parent company + if (! empty($arrayfields['s.fk_parent']['checked'])) + { + print '"; + if (! $i) $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook From 5516cb061d7e0e78ab5abc1975a39bbbb2d96d89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Feb 2019 18:50:34 +0100 Subject: [PATCH 46/77] Fix filter --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 768f99c8182..14c2a95e370 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -941,7 +941,7 @@ if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titr if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['s.fk_parent']['checked'])) print_liste_field_titre($arrayfields['s.fk_parent']['label'], $_SERVER["PHP_SELF"], "s.parent", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['s.fk_parent']['checked'])) print_liste_field_titre($arrayfields['s.fk_parent']['label'], $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields From 6ee5a9e2a6784ee508aee3b9638c9f3835296313 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 7 Feb 2019 12:21:33 +0100 Subject: [PATCH 47/77] fix travis --- htdocs/core/class/html.formcompany.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d28b867dc93..282320444cd 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -889,7 +889,18 @@ class FormCompany } } - function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname='customerprospect', $typeinput='form',$morecss = '') { + /** + * Return a HTML select for thirdparty type + * + * @param int $selected selected value + * @param string $htmlname HTML select name + * @param string $htmlidname HTML select id + * @param string $typeinput HTML output + * @param string $morecss More css + * @return string HTML string + */ + function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') + { global $conf,$langs; From 8e6a567b091795e9641ea6b234b4a43aaaa93d56 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 12:36:22 +0100 Subject: [PATCH 48/77] Fix display payment table on multiple pages --- .../modules/facture/doc/pdf_crabe.modules.php | 82 ++++++++++++++----- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4c0724d393d..91d20d4830b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -706,7 +706,7 @@ class pdf_crabe extends ModelePDFFactures // Affiche zone versements if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter); } // Pied de page @@ -751,15 +751,17 @@ class pdf_crabe extends ModelePDFFactures * @param Object $object Object invoice * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output + * @param int $heightforfooter height for footer * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter) { global $conf; $sign=1; if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $current_page = $pdf->getPage(); $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -771,26 +773,7 @@ class pdf_crabe extends ModelePDFFactures $default_font_size = pdf_getPDFFontSize($outputlangs); - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); - - $pdf->SetFont('','', $default_font_size - 3); - $pdf->SetXY($tab3_posx, $tab3_top - 4); - $pdf->MultiCell(60, 3, $title, 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); - - $pdf->SetFont('','', $default_font_size - 4); - $pdf->SetXY($tab3_posx, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height); $y=0; @@ -812,6 +795,17 @@ class pdf_crabe extends ModelePDFFactures while ($i < $num) { $y+=3; + if ($tab3_top+$y >= $this->page_hauteur-$heightforfooter) + { + $y=0; + $current_page++; + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($current_page); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top+$y-3, $tab3_width, $tab3_height); + } + $obj = $this->db->fetch_object($resql); if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote"); @@ -858,6 +852,17 @@ class pdf_crabe extends ModelePDFFactures $i=0; while ($i < $num) { $y+=3; + if ($tab3_top+$y >= $this->page_hauteur-$heightforfooter) + { + $y=0; + $current_page++; + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($current_page); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top+$y-3, $tab3_width, $tab3_height); + } + $row = $this->db->fetch_object($resql); $pdf->SetXY($tab3_posx, $tab3_top+$y); @@ -884,6 +889,39 @@ class pdf_crabe extends ModelePDFFactures } + /** + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice + * @param Translate $outputlangs Object langs for output + * @param int $default_font_size Font size + * @param int $tab3_posx pos x + * @param int $tab3_top pos y + * @param int $tab3_width width + * @param int $tab3_height height + */ + function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) + { + $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); + if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); + + $pdf->SetFont('','', $default_font_size - 3); + $pdf->SetXY($tab3_posx, $tab3_top - 4); + $pdf->MultiCell(60, 3, $title, 0, 'L', 0); + + $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); + + $pdf->SetFont('','', $default_font_size - 4); + $pdf->SetXY($tab3_posx, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+21, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+40, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+58, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); + + $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); + } /** * Show miscellaneous information (payment mode, payment term, ...) From 6a4a92510d7e96648c49f9f51d0d476ba7414697 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 13:32:05 +0100 Subject: [PATCH 49/77] Code comment --- htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 31646b9f852..8182b479aa9 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** - * Classe permettant de generer les projets au modele SEPAMandate + * Class to generate SEPA mandate */ class pdf_sepamandate extends ModeleBankAccountDoc From 2ef8544a39aa7e9aa05eec6787061f8055c8aa3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 13:52:51 +0100 Subject: [PATCH 50/77] sort and filter on parent company --- htdocs/societe/list.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 14c2a95e370..c063d915036 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -92,7 +92,7 @@ $search_stcomm=GETPOST('search_stcomm', 'int'); $search_import_key = GETPOST("search_import_key", "alpha"); $search_btn=GETPOST('button_search', 'alpha'); $search_remove_btn=GETPOST('button_removefilter', 'alpha'); -$search_fk_parent = GETPOST('search_fk_parent', 'alpha'); +$search_parent_name = GETPOST('search_parent_name', 'alpha'); $type=GETPOST('type', 'alpha'); $optioncss=GETPOST('optioncss', 'alpha'); @@ -196,7 +196,7 @@ $arrayfields=array( 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), - 's.fk_parent'=>array('label'=>'ParentCompany', 'checked'=>0), + 's2.nom'=>array('label'=>'ParentCompany', 'checked'=>0), 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -265,7 +265,7 @@ if (empty($reshook)) $search_status=-1; $search_stcomm=''; $search_level=''; - $search_fk_parent=-1; + $search_parent_name=-1; $search_import_key=''; $toselect=''; $search_array_options=array(); @@ -347,6 +347,7 @@ $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.p $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; +$sql.= " s2.nom as name,"; $sql.= " typent.code as typent_code,"; $sql.= " staff.code as staff_code,"; $sql.= " country.code as country_code,"; @@ -364,6 +365,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; @@ -423,7 +425,7 @@ if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2); if (! empty($search_staff) && $search_staff != '-1') $sql.= natural_search("s.fk_effectif", $search_staff, 2); if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); -if ($search_fk_parent && $search_fk_parent != '-1') $sql.= "s.fk_parent IN (".$search_fk_parent.")"; +if ($search_parent_name) $sql.= natural_search("s2.nom", $search_parent_name); if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2); if ($search_import_key) $sql.= natural_search("s.import_key", $search_import_key); // Add where from extra fields @@ -520,7 +522,7 @@ if ($search_type != '') $param.='&search_type='.urlencode($search_type); if (is_array($search_level) && count($search_level)) foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); -if ($search_fk_parent != '' && $search_fk_parent != '-1') $param.='&search_fk_parent='.urlencode($search_fk_parent); +if ($search_parent_name != '') $param.='&search_parent_name='.urlencode($search_parent_name); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); if ($type != '') $param.='&type='.urlencode($type); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); @@ -865,10 +867,10 @@ if (! empty($arrayfields['s.fk_stcomm']['checked'])) print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); print ''; } -if (! empty($arrayfields['s.fk_parent']['checked'])) +if (! empty($arrayfields['s2.nom']['checked'])) { print ''; } // Extra fields @@ -941,7 +943,7 @@ if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titr if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, 'align="center"', $sortfield, $sortorder); -if (! empty($arrayfields['s.fk_parent']['checked'])) print_liste_field_titre($arrayfields['s.fk_parent']['label'], $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder); +if (! empty($arrayfields['s2.nom']['checked'])) print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1196,7 +1198,7 @@ while ($i < min($num, $limit)) if (! $i) $totalarray['nbfield']++; } // Parent company - if (! empty($arrayfields['s.fk_parent']['checked'])) + if (! empty($arrayfields['s2.nom']['checked'])) { print '"; if (! $i) $totalarray['nbfield']++; From 0156cd40a6eaaaa9f5db5fa4532d8822dd9e3b19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 14:00:32 +0100 Subject: [PATCH 52/77] Fix name --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3a1744451c1..ce35649c6c6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -347,7 +347,7 @@ $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.p $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; -$sql.= " s2.nom as name,"; +$sql.= " s2.nom as name2,"; $sql.= " typent.code as typent_code,"; $sql.= " staff.code as staff_code,"; $sql.= " country.code as country_code,"; From 9d0e0c2798127d3324a61bf148dd2490200b3121 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 7 Feb 2019 15:17:52 +0100 Subject: [PATCH 53/77] FIX add fk_unit on addline action --- htdocs/supplier_proposal/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e47dc48d6ca..7b1bf417b40 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -634,6 +634,8 @@ if (empty($reshook)) $ref_supplier = $productsupplier->ref_supplier; + $fk_unit = $productsupplier->fk_unit; + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice','alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice','alpha')); if (empty($tva_tx)) $tva_npr=0; From ec7ef265b7a0230ea6b993139def74937d1fdc7a Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 17:47:17 +0100 Subject: [PATCH 54/77] Fix psql search insensitive accent --- htdocs/core/db/pgsql.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 8e57b29109e..392e0998d6b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -152,6 +152,7 @@ class DoliDBPgsql extends DoliDB */ static function convertSQLFromMysql($line,$type='auto',$unescapeslashquot=false) { + global $conf; // Removed empty line if this is a comment line for SVN tagging if (preg_match('/^--\s\$Id/i',$line)) { return ''; @@ -311,7 +312,14 @@ class DoliDBPgsql extends DoliDB } // To have postgresql case sensitive - $line=str_replace(' LIKE \'',' ILIKE \'',$line); + $count_like=0; + $line=str_replace(' LIKE \'',' ILIKE \'',$line,$count_like); + if (!empty($conf->global->PSQL_USE_UNACCENT) && $count_like > 0) + { + // @see https://docs.postgresql.fr/11/unaccent.html : 'unaccent()' function must be installed before + $line=preg_replace('/\s+(\(?\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); + } + $line=str_replace(' LIKE BINARY \'',' LIKE \'',$line); // Replace INSERT IGNORE into INSERT From 51515a487ed72eabd7a5fbbade31a0a7d50d80b9 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 17:58:25 +0100 Subject: [PATCH 55/77] Fix search unaccent from left menu search box --- htdocs/core/db/pgsql.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 392e0998d6b..3d365142a0a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -317,7 +317,7 @@ class DoliDBPgsql extends DoliDB if (!empty($conf->global->PSQL_USE_UNACCENT) && $count_like > 0) { // @see https://docs.postgresql.fr/11/unaccent.html : 'unaccent()' function must be installed before - $line=preg_replace('/\s+(\(?\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); + $line=preg_replace('/\s+(\(+\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); } $line=str_replace(' LIKE BINARY \'',' LIKE \'',$line); From 89af7b0e98566d02b425b4bbd88ed78cef927fca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 19:38:36 +0100 Subject: [PATCH 56/77] Add doctype to web site --- htdocs/core/lib/website.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index da16b0846c5..fe5387094ba 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -667,6 +667,10 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n"; $tplcontent.= "ob_start();\n"; $tplcontent.= "// END PHP ?>\n"; + if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5)) + { + $tplcontent.= ""; + } $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n"; From 8d8213503337b66a3b2dbe1c55ba12c66934178b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 19:39:23 +0100 Subject: [PATCH 57/77] Fix missing \n --- htdocs/core/lib/website.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index fe5387094ba..6f1057936d8 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -669,7 +669,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= "// END PHP ?>\n"; if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5)) { - $tplcontent.= ""; + $tplcontent.= "\n"; } $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; From 48eba7c71ba6dd087e5488991e488072713e3c4f Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Fri, 8 Feb 2019 08:41:26 +0100 Subject: [PATCH 58/77] use font awesome for the top menu icons --- htdocs/theme/eldy/main_menu_fa_icons.css | 151 ++++++++++++++ htdocs/theme/eldy/style.css.php | 252 +++++++++++------------ 2 files changed, 277 insertions(+), 126 deletions(-) create mode 100644 htdocs/theme/eldy/main_menu_fa_icons.css diff --git a/htdocs/theme/eldy/main_menu_fa_icons.css b/htdocs/theme/eldy/main_menu_fa_icons.css new file mode 100644 index 00000000000..44cd7b99044 --- /dev/null +++ b/htdocs/theme/eldy/main_menu_fa_icons.css @@ -0,0 +1,151 @@ +div.mainmenu.home::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f015"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.billing::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f0d6"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.accountancy::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f0d6"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.agenda::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f073"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.bank::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f19c"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.cashdesk::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f788"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.takepos::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f788"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.companies::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f1ad"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.commercial::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f508"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.ecm::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f07c"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.externalsite::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f360"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.ftp::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f362"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.hrm::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f5ca"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.members::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f0c0"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.products::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f468"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.project::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f542"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.ticket::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f3ff"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.tools::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f0ad"; + color: white; + font-size: 1.5em; +} + +div.mainmenu.website::before { + font-family: "Font Awesome 5 Free"; + font-weight: 900; + content: "\f0e8"; + color: white; + font-size: 1.5em; +} \ No newline at end of file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4e65b1bc5ed..3b2481554cd 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1716,155 +1716,155 @@ a.tmenuimage { /* Do not load menu img for other if hidden to save bandwidth */ - + + global->MAIN_USE_FONT_AWESOME_5)): ?> + + + div.mainmenu.home{ + background-image: url(); + background-position-x: center; + } -div.mainmenu.home{ - background-image: url(); - background-position-x: center; -} + div.mainmenu.billing { + background-image: url(); + } -div.mainmenu.billing { - background-image: url(); -} + div.mainmenu.accountancy { + background-image: url(); + } -div.mainmenu.accountancy { - background-image: url(); -} + div.mainmenu.agenda { + background-image: url(); + } -div.mainmenu.agenda { - background-image: url(); -} + div.mainmenu.bank { + background-image: url(); + } -div.mainmenu.bank { - background-image: url(); -} + div.mainmenu.cashdesk { + background-image: url(); + } -div.mainmenu.cashdesk { - background-image: url(); -} + div.mainmenu.takepos { + background-image: url(); + } -div.mainmenu.takepos { - background-image: url(); -} + div.mainmenu.companies { + background-image: url(); + } -div.mainmenu.companies { - background-image: url(); -} + div.mainmenu.commercial { + background-image: url(); + } -div.mainmenu.commercial { - background-image: url(); -} + div.mainmenu.ecm { + background-image: url(); + } -div.mainmenu.ecm { - background-image: url(); -} + div.mainmenu.externalsite { + background-image: url(); + } -div.mainmenu.externalsite { - background-image: url(); -} + div.mainmenu.ftp { + background-image: url(); + } -div.mainmenu.ftp { - background-image: url(); -} + div.mainmenu.hrm { + background-image: url(); + } -div.mainmenu.hrm { - background-image: url(); -} + div.mainmenu.members { + background-image: url(); + } -div.mainmenu.members { - background-image: url(); -} + div.mainmenu.products { + background-image: url(); + } -div.mainmenu.products { - background-image: url(); -} + div.mainmenu.project { + background-image: url(); + } -div.mainmenu.project { - background-image: url(); -} + div.mainmenu.ticket { + background-image: url(); + } -div.mainmenu.ticket { - background-image: url(); -} + div.mainmenu.tools { + background-image: url(); + } -div.mainmenu.tools { - background-image: url(); -} + div.mainmenu.website { + background-image: url(); + } -div.mainmenu.website { - background-image: url(); -} + 'name of class for div') -'name of class for div') + $moduletomainmenu=array( + 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', + 'produit'=>'products','service'=>'products','stock'=>'products', + 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', + 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', + 'fournisseur'=>'companies', + 'barcode'=>'','fckeditor'=>'','categorie'=>'', + ); + $mainmenuused='home'; + foreach($conf->modules as $val) + { + $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); + } + $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); -$moduletomainmenu=array( - 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', - 'produit'=>'products','service'=>'products','stock'=>'products', - 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', - 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', - 'fournisseur'=>'companies', - 'barcode'=>'','fckeditor'=>'','categorie'=>'', -); -$mainmenuused='home'; -foreach($conf->modules as $val) -{ - $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); -} -//var_dump($mainmenuused); -$mainmenuusedarray=array_unique(explode(',',$mainmenuused)); + $generic=1; + // Put here list of menu entries when the div.mainmenu.menuentry was previously defined + $divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); + // Put here list of menu entries we are sure we don't want + $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); + foreach($mainmenuusedarray as $val) + { + if (empty($val) || in_array($val,$divalreadydefined)) continue; + if (in_array($val,$divnotrequired)) continue; + //print "XXX".$val; -$generic=1; -// Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); -// Put here list of menu entries we are sure we don't want -$divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); -foreach($mainmenuusedarray as $val) -{ - if (empty($val) || in_array($val,$divalreadydefined)) continue; - if (in_array($val,$divnotrequired)) continue; - //print "XXX".$val; + // Search img file in module dir + $found=0; $url=''; + foreach($conf->file->dol_document_root as $dirroot) + { + if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); + $found=1; + break; + } + } + // Img file not found + if (! $found) + { + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png",1); + $found=1; + if ($generic < 4) $generic++; + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + } + if ($found) + { + print "div.mainmenu.".$val." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; + } + } + $j=0; + while ($j++ < 4) + { + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png",1); + print "div.mainmenu.generic".$j." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; + } + // End of part to add more div class css + ?> - // Search img file in module dir - $found=0; $url=''; - foreach($conf->file->dol_document_root as $dirroot) - { - if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) - { - $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); - $found=1; - break; - } - } - // Img file not found - if (! $found) - { - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png",1); - $found=1; - if ($generic < 4) $generic++; - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - } - if ($found) - { - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; - } -} -$j=0; -while ($j++ < 4) -{ - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png",1); - print "div.mainmenu.generic".$j." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; -} -// End of part to add more div class css -?> - - + + .tmenuimage { padding:0 0 0 0 !important; From 8abebb091c16343c66de43b7fa6668d093bb38ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 09:33:01 +0100 Subject: [PATCH 59/77] Var no more used --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0a0e2ad7cd5..73b2bfdb314 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -108,7 +108,7 @@ if ($id > 0 || ! empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicecard','globalcard')); -$usercancreate = $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php From 3f01cd554bf561ef646647c82003c1092d977120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 09:50:45 +0100 Subject: [PATCH 60/77] Update agentMargins.php --- htdocs/margin/agentMargins.php | 41 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 0ad6563767c..aae859666e7 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -214,32 +214,31 @@ if ($result) { $objp = $db->fetch_object($result); - $seller_nb = 1; - if ($objp->socid > 0) { - // sql nb sellers - $sql_seller = "SELECT COUNT(sc.rowid) as nb"; - $sql_seller .= " FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; - $sql_seller .= " WHERE sc.fk_soc = " . $objp->socid; - $sql_seller .= " LIMIT 1"; + $seller_nb = 1; + if ($objp->socid > 0) { + // sql nb sellers + $sql_seller = "SELECT COUNT(sc.rowid) as nb"; + $sql_seller .= " FROM " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; + $sql_seller .= " WHERE sc.fk_soc = " . $objp->socid; - $resql_seller = $db->query($sql_seller); - if (!$resql_seller) { - dol_print_error($db); - } else { - if ($obj_seller = $db->fetch_object($resql_seller)) { - if ($obj_seller->nb > 0) { - $seller_nb = $obj_seller->nb; + $resql_seller = $db->query($sql_seller); + if (!$resql_seller) { + dol_print_error($db); + } else { + if ($obj_seller = $db->fetch_object($resql_seller)) { + if ($obj_seller->nb > 0) { + $seller_nb = $obj_seller->nb; + } + } } } - } - } - $pa = $objp->buying_price / $seller_nb; - $pv = $objp->selling_price / $seller_nb; - $marge = $objp->marge / $seller_nb; + $pa = $objp->buying_price / $seller_nb; + $pv = $objp->selling_price / $seller_nb; + $marge = $objp->marge / $seller_nb; - $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; - $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; print ''; if ($agentid > 0) { From fbd2d368e48de357234c7bfc390d3f99e76faaf4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:19:59 +0100 Subject: [PATCH 61/77] Update style.css.php --- htdocs/theme/eldy/style.css.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 1822b1071dd..14cb118c8d1 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1717,9 +1717,9 @@ a.tmenuimage { /* Do not load menu img for other if hidden to save bandwidth */ - global->MAIN_USE_FONT_AWESOME_5)): ?> - - + global->MAIN_USE_FONT_AWESOME_5)) { ?> + + div.mainmenu.home{ background-image: url(); background-position-x: center; @@ -1863,8 +1863,8 @@ a.tmenuimage { // End of part to add more div class css ?> - - + + .tmenuimage { padding:0 0 0 0 !important; From 43fbcf7081cd5a2dcb51153ce47c0e926053f31e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:28:59 +0100 Subject: [PATCH 62/77] Prepare 8.0.5 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 36e3ba38b58..3981de21751 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','8.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','8.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 26860620319457c881a916ef96031dc12e656784 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:30:07 +0100 Subject: [PATCH 63/77] Prepare version 9.0.1 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b98c91add1a..b2213c5d03c 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.0'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 3a5fc8f0c375dca22d36049aa0923d2c4aed7af5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:41:11 +0100 Subject: [PATCH 64/77] NEW Add protection to avoid packaging if files non indexed exists into dir. --- build/makepack-dolibarr.pl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index bbdfa564183..16b4f64a0d2 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -387,6 +387,15 @@ if ($nboftargetok) { #----------------------- if ($CHOOSEDTARGET{'-CHKSUM'}) { + $ret=`git ls-files . --exclude-standard --others`; + if ($ret) + { + print "Some files exists in source directory and are not indexed neither excluded in .gitignore.\n"; + print $ret; + print "Canceled.\n"; + exit; + } + print 'Create xml check file with md5 checksum with command php '.$SOURCE.'/build/generate_filelist_xml.php release='.$MAJOR.'.'.$MINOR.'.'.$BUILD."\n"; $ret=`php $SOURCE/build/generate_filelist_xml.php release=$MAJOR.$MINOR.$BUILD`; print $ret."\n"; From 662ed9fba7133a59124003fdf4c7d2beaf2a6200 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:47:25 +0100 Subject: [PATCH 65/77] Prepare 9.0.1 --- ChangeLog | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 39c4d5d6ca8..e87c9c14f8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,27 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 9.0.1 compared to 9.0.0 ***** +FIX: #10381 +FIX: #10460 compatibility with MariaDB 10.4 +FIX: #10485 +FIX: add fk_unit on addline action +FIX: better test on fetch +FIX: Default language of company is not set +FIX: error report not returned +FIX: expedition: reset status on rollback + replace hardcoded status with const +FIX: line edit template: keep fk_parent_line +FIX: Missing province in export of invoice +FIX: must fetch member in current entity +FIX: Price in combo list of service does not use the correct price level +FIX: supplier invoice payment total doesnt care about deposit or credit +FIX: supplier invoice product stats total ht is line total not invoice total +FIX: Translation not loaded by scheduled jobs +FIX: [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 - can't add lines on invoices +FIX: wrong merged conflict +FIX: wrong tests on fetch +NEW: Add protection to avoid packaging if files non indexed exists into + ***** ChangeLog for 9.0.0 compared to 8.0.0 ***** For Users: NEW: Stable module: DAV (WebDAV only for the moment) From 9b2a91893d956f7af47ebe17931aef7e33ce81ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:49:02 +0100 Subject: [PATCH 66/77] Update doc --- ChangeLog | 1 - 1 file changed, 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e87c9c14f8b..441bbb189b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,6 @@ FIX: Price in combo list of service does not use the correct price level FIX: supplier invoice payment total doesnt care about deposit or credit FIX: supplier invoice product stats total ht is line total not invoice total FIX: Translation not loaded by scheduled jobs -FIX: [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 - can't add lines on invoices FIX: wrong merged conflict FIX: wrong tests on fetch NEW: Add protection to avoid packaging if files non indexed exists into From 14a48b2c95fadac01b7e97debe838e55edcef9e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 11:17:04 +0100 Subject: [PATCH 67/77] Fix phpcs --- htdocs/societe/admin/societe.php | 2 +- htdocs/societe/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index e283d3220b2..ba6d8522ccf 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -882,7 +882,7 @@ print ''; print ''; print ''; print ''; print ''; } // Prospect level From 512ceae70a138e5210e70085208d5e58b549f69a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 11:27:30 +0100 Subject: [PATCH 68/77] Fix phpcs --- htdocs/fourn/facture/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 82cb0314de9..461a1532290 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -621,7 +621,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; From ec686a8f79e1a7b93340f412dd70d287beee6795 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 11:30:20 +0100 Subject: [PATCH 69/77] Fix phpcs --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 37812647caa..6165e948fd0 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -924,7 +924,9 @@ class pdf_crabe extends ModelePDFFactures } /** - * @param PDF $pdf Object PDF + * Function _tableau_versements_header + * + * @param TCPDF $pdf Object PDF * @param Facture $object Object invoice * @param Translate $outputlangs Object langs for output * @param int $default_font_size Font size @@ -932,6 +934,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $tab3_top pos y * @param int $tab3_width width * @param int $tab3_height height + * @return void */ function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { From b3f955e9a590e9d6fbca8519606f1bc1e688fd1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 11:55:27 +0100 Subject: [PATCH 70/77] Fix syntax error --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 14cb118c8d1..01da724c20e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1718,7 +1718,7 @@ a.tmenuimage { global->MAIN_USE_FONT_AWESOME_5)) { ?> - + div.mainmenu.home{ background-image: url(); From 78fbeeaa625a3a0107a4b26c240a36079438dc0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 11:57:39 +0100 Subject: [PATCH 71/77] Fix syntax error --- htdocs/theme/eldy/style.css.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 01da724c20e..556d7da8d87 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1716,9 +1716,9 @@ a.tmenuimage { /* Do not load menu img for other if hidden to save bandwidth */ - + global->MAIN_USE_FONT_AWESOME_5)) { ?> - + div.mainmenu.home{ background-image: url(); From 5043aa7b3554073390b24e26c600f53af03fa35c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 12:17:11 +0100 Subject: [PATCH 72/77] Fix regression for icon of external menus --- htdocs/theme/eldy/main_menu_fa_icons.css | 6 +- htdocs/theme/eldy/style.css.php | 113 +++++++++++------------ 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/htdocs/theme/eldy/main_menu_fa_icons.css b/htdocs/theme/eldy/main_menu_fa_icons.css index 44cd7b99044..58890786111 100644 --- a/htdocs/theme/eldy/main_menu_fa_icons.css +++ b/htdocs/theme/eldy/main_menu_fa_icons.css @@ -49,7 +49,7 @@ div.mainmenu.cashdesk::before { div.mainmenu.takepos::before { font-family: "Font Awesome 5 Free"; font-weight: 900; - content: "\f788"; + content: "\f217"; color: white; font-size: 1.5em; } @@ -121,7 +121,7 @@ div.mainmenu.products::before { div.mainmenu.project::before { font-family: "Font Awesome 5 Free"; font-weight: 900; - content: "\f542"; + content: "\f0e8"; color: white; font-size: 1.5em; } @@ -145,7 +145,7 @@ div.mainmenu.tools::before { div.mainmenu.website::before { font-family: "Font Awesome 5 Free"; font-weight: 900; - content: "\f0e8"; + content: "\f542"; color: white; font-size: 1.5em; } \ No newline at end of file diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 556d7da8d87..7cb9c7c29b7 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1796,74 +1796,73 @@ a.tmenuimage { div.mainmenu.website { background-image: url(); } + - 'name of class for div') + 'name of class for div') - $moduletomainmenu=array( - 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', - 'produit'=>'products','service'=>'products','stock'=>'products', - 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', - 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', - 'fournisseur'=>'companies', - 'barcode'=>'','fckeditor'=>'','categorie'=>'', - ); - $mainmenuused='home'; - foreach($conf->modules as $val) + $moduletomainmenu=array( + 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', + 'produit'=>'products','service'=>'products','stock'=>'products', + 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', + 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', + 'fournisseur'=>'companies', + 'barcode'=>'','fckeditor'=>'','categorie'=>'', + ); + $mainmenuused='home'; + foreach($conf->modules as $val) + { + $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); + } + $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); + + $generic=1; + // Put here list of menu entries when the div.mainmenu.menuentry was previously defined + $divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); + // Put here list of menu entries we are sure we don't want + $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); + foreach($mainmenuusedarray as $val) + { + if (empty($val) || in_array($val,$divalreadydefined)) continue; + if (in_array($val,$divnotrequired)) continue; + //print "XXX".$val; + + // Search img file in module dir + $found=0; $url=''; + foreach($conf->file->dol_document_root as $dirroot) { - $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); - } - $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); - - $generic=1; - // Put here list of menu entries when the div.mainmenu.menuentry was previously defined - $divalreadydefined=array('home','companies','products','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); - // Put here list of menu entries we are sure we don't want - $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); - foreach($mainmenuusedarray as $val) - { - if (empty($val) || in_array($val,$divalreadydefined)) continue; - if (in_array($val,$divnotrequired)) continue; - //print "XXX".$val; - - // Search img file in module dir - $found=0; $url=''; - foreach($conf->file->dol_document_root as $dirroot) + if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) { - if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) - { - $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); - $found=1; - break; - } - } - // Img file not found - if (! $found) - { - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png",1); + $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); $found=1; - if ($generic < 4) $generic++; - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - } - if ($found) - { - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; + break; } } - $j=0; - while ($j++ < 4) + // Img file not found + if (! $found) { - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png",1); - print "div.mainmenu.generic".$j." {\n"; + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png",1); + $found=1; + if ($generic < 4) $generic++; + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + } + if ($found) + { + print "div.mainmenu.".$val." {\n"; print " background-image: url(".$url.");\n"; print "}\n"; } - // End of part to add more div class css - ?> - - + } + $j=0; + while ($j++ < 4) + { + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png",1); + print "div.mainmenu.generic".$j." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; + } + // End of part to add more div class css + ?> .tmenuimage { From 1611c613f56c541ea23242bf88466e6630442f88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 12:19:51 +0100 Subject: [PATCH 73/77] Fix phpcs --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6165e948fd0..c22b1d23ef7 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -923,6 +923,7 @@ class pdf_crabe extends ModelePDFFactures } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function _tableau_versements_header * @@ -938,7 +939,8 @@ class pdf_crabe extends ModelePDFFactures */ function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); + // phpcs:enable + $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); $pdf->SetFont('','', $default_font_size - 3); From a40d4ddbaa07c850735924456656de49e24d0013 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 12:23:04 +0100 Subject: [PATCH 74/77] Fix phpcs --- htdocs/theme/eldy/style.css.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7cb9c7c29b7..1ac76554549 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1814,7 +1814,7 @@ a.tmenuimage { { $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); } - $mainmenuusedarray=array_unique(explode(',',$mainmenuused)); + $mainmenuusedarray=array_unique(explode(',', $mainmenuused)); $generic=1; // Put here list of menu entries when the div.mainmenu.menuentry was previously defined @@ -1823,8 +1823,8 @@ a.tmenuimage { $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); foreach($mainmenuusedarray as $val) { - if (empty($val) || in_array($val,$divalreadydefined)) continue; - if (in_array($val,$divnotrequired)) continue; + if (empty($val) || in_array($val, $divalreadydefined)) continue; + if (in_array($val, $divnotrequired)) continue; //print "XXX".$val; // Search img file in module dir @@ -1841,7 +1841,7 @@ a.tmenuimage { // Img file not found if (! $found) { - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png",1); + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic."_over.png", 1); $found=1; if ($generic < 4) $generic++; print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; @@ -1856,7 +1856,7 @@ a.tmenuimage { $j=0; while ($j++ < 4) { - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png",1); + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$j."_over.png", 1); print "div.mainmenu.generic".$j." {\n"; print " background-image: url(".$url.");\n"; print "}\n"; From 27da574e38e762559c45048ebbd1118d0deb6cd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 12:36:33 +0100 Subject: [PATCH 75/77] Fix phpcs --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 5d9c156acc5..9a1caf75b1c 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -834,7 +834,7 @@ class pdf_crabe extends ModelePDFFactures { $y=0; $current_page++; - $pdf->AddPage('','',true); + $pdf->AddPage('', '', true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($current_page); @@ -891,7 +891,7 @@ class pdf_crabe extends ModelePDFFactures { $y=0; $current_page++; - $pdf->AddPage('','',true); + $pdf->AddPage('', '', true); if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($current_page); @@ -933,6 +933,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $tab3_top pos y * @param int $tab3_width width * @param int $tab3_height height + * @return void */ function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { From 766ef36ea3124f97941fe03737a301b7cd400744 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 13:26:59 +0100 Subject: [PATCH 76/77] Standardize code of page of leave movements --- htdocs/holiday/view_log.php | 151 ++++++++++++++++++++++++++++++++---- 1 file changed, 134 insertions(+), 17 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 1051fca8ba3..d64d85813e6 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -28,46 +28,143 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +$action = GETPOST('action', 'aZ09')?GETPOST('action', 'aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +$search_id = GETPOST('search_id', 'alpha'); +$year=GETPOST('year'); +if (empty($year)) +{ + $tmpdate=dol_getdate(dol_now()); + $year=$tmpdate['year']; +} + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + + // Protection if external user if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page if(!$user->rights->holiday->read_all) accessforbidden(); -$year=GETPOST('year'); -if (empty($year)) -{ - $tmpdate=dol_getdate(dol_now()); - $year=$tmpdate['year']; -} - // Load translation files required by the page $langs->load('users'); +// Initialize technical objects +$object = new Holiday($db); +$extrafields = new ExtraFields($db); +//$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_modules contains array + +$arrayfields=array(); +$arrayofmassactions=array(); + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_id=''; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} + + /* * View */ -$cp = new Holiday($db); +$form = new Form($db); -$alltypeleaves=$cp->getTypes(1, -1); // To have labels +$alltypeleaves=$object->getTypes(1, -1); // To have labels llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); -// Recent changes are more important than old changes -$log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"); // Load $cp->logs -$pagination=''; + +$sqlwhere = ''; +$sqlwhere.= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"; +if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1); + +$sqlorder = 'ORDER BY cpl.rowid DESC'; + +// Recent changes are more important than old changes +$log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($search_id) $param='&search_id='.urlencode($search_id); + +print '
    '; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$pagination=''; print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png'); print '
    '.$langs->trans('LastUpdateCP').': '."\n"; -$lastUpdate = $cp->getConfCP('lastUpdate'); +$lastUpdate = $object->getConfCP('lastUpdate'); if ($lastUpdate) { $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; - print ''.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; + print ''.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; print '
    '.$langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.''."\n"; } else print $langs->trans('None'); @@ -75,12 +172,18 @@ print "

    \n"; $moreforfilter=''; +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); +$selectedfields=''; + print '
    '; print '
    '; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9a3dd044923..23e40ccc317 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -831,13 +831,14 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) { print ''; if ($type != '') print ''; - print ''; print ''; if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print ''; //if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print ''; print ''; - print ''; + print '';*/ print ''; if ($type != '') print ''; print $formcompany->selectProspectCustomerType($search_type,'search_type', 'search_type', 'list'); - /*print '
    '.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; $selected=GETPOST('client', 'int')!=''?GETPOST('client', 'int'):$object->client; - print $formcompany->selectProspectCustomerType($selected,'client'); + print $formcompany->selectProspectCustomerType($selected); print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; @@ -1772,7 +1772,7 @@ else // Prospect/Customer print '
    '.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; - print $formcompany->selectProspectCustomerType($object->client,'client'); + print $formcompany->selectProspectCustomerType($object->client); print ''.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; From f0f0b69d87d0ea04a49d3045f392868391330202 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 10:59:24 +0100 Subject: [PATCH 42/77] add comment --- htdocs/societe/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index a2c2acdd9a7..69f3f9b880d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -937,6 +937,7 @@ else $object->client=-1; if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } } + // Prospect / Customer if (GETPOST("type")=='c') { if (! empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { $object->client=$conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; From 29e4fce45084965b5d3d036be84761d121ad3e8c Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 6 Feb 2019 12:35:23 +0100 Subject: [PATCH 43/77] FIX : can't add lines on invoices --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4881e42abf1..0aaac3f8f2e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -108,7 +108,7 @@ if ($id > 0 || ! empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicecard','globalcard')); -$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$usercancreate = $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php From c0686733e889a73527a56e7ea6a4ffa31e3a4cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 6 Feb 2019 15:56:13 +0100 Subject: [PATCH 44/77] fix phpcs --- htdocs/admin/tools/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 7b37e7112f3..a833b5160b9 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -40,7 +40,7 @@ $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search','alpha') || GETPOST('button_removefilter','alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; From d960159b73c46f15c334b2fa7d6fc609f245f353 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Feb 2019 18:49:58 +0100 Subject: [PATCH 45/77] NEW Column of parent company is available in list of third parties --- htdocs/societe/list.php | 76 +++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9a3dd044923..768f99c8182 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -56,29 +56,29 @@ $search_all=trim(GETPOST('search_all', 'alphanohtml')?GETPOST('search_all', 'alp $search_cti=preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars $search_id=trim(GETPOST("search_id", "int")); -$search_nom=trim(GETPOST("search_nom")); -$search_alias=trim(GETPOST("search_alias")); -$search_nom_only=trim(GETPOST("search_nom_only")); -$search_barcode=trim(GETPOST("search_barcode")); -$search_customer_code=trim(GETPOST('search_customer_code')); -$search_supplier_code=trim(GETPOST('search_supplier_code')); -$search_account_customer_code=trim(GETPOST('search_account_customer_code')); -$search_account_supplier_code=trim(GETPOST('search_account_supplier_code')); -$search_town=trim(GETPOST("search_town")); -$search_zip=trim(GETPOST("search_zip")); -$search_state=trim(GETPOST("search_state")); -$search_region=trim(GETPOST("search_region")); -$search_email=trim(GETPOST('search_email')); -$search_phone=trim(GETPOST('search_phone')); -$search_fax=trim(GETPOST('search_fax')); -$search_url=trim(GETPOST('search_url')); -$search_idprof1=trim(GETPOST('search_idprof1')); -$search_idprof2=trim(GETPOST('search_idprof2')); -$search_idprof3=trim(GETPOST('search_idprof3')); -$search_idprof4=trim(GETPOST('search_idprof4')); -$search_idprof5=trim(GETPOST('search_idprof5')); -$search_idprof6=trim(GETPOST('search_idprof6')); -$search_vat=trim(GETPOST('search_vat')); +$search_nom=trim(GETPOST("search_nom", 'none')); +$search_alias=trim(GETPOST("search_alias", 'none')); +$search_nom_only=trim(GETPOST("search_nom_only", 'none')); +$search_barcode=trim(GETPOST("search_barcode", 'alpha')); +$search_customer_code=trim(GETPOST('search_customer_code', 'alpha')); +$search_supplier_code=trim(GETPOST('search_supplier_code', 'alpha')); +$search_account_customer_code=trim(GETPOST('search_account_customer_code', 'alpha')); +$search_account_supplier_code=trim(GETPOST('search_account_supplier_code', 'alpha')); +$search_town=trim(GETPOST("search_town", 'alpha')); +$search_zip=trim(GETPOST("search_zip", 'alpha')); +$search_state=trim(GETPOST("search_state", 'alpha')); +$search_region=trim(GETPOST("search_region", 'alpha')); +$search_email=trim(GETPOST('search_email', 'alpha')); +$search_phone=trim(GETPOST('search_phone', 'alpha')); +$search_fax=trim(GETPOST('search_fax', 'alpha')); +$search_url=trim(GETPOST('search_url', 'alpha')); +$search_idprof1=trim(GETPOST('search_idprof1', 'alpha')); +$search_idprof2=trim(GETPOST('search_idprof2', 'alpha')); +$search_idprof3=trim(GETPOST('search_idprof3', 'alpha')); +$search_idprof4=trim(GETPOST('search_idprof4', 'alpha')); +$search_idprof5=trim(GETPOST('search_idprof5', 'alpha')); +$search_idprof6=trim(GETPOST('search_idprof6', 'alpha')); +$search_vat=trim(GETPOST('search_vat', 'alpha')); $search_sale=trim(GETPOST("search_sale", 'int')); $search_categ_cus=trim(GETPOST("search_categ_cus", 'int')); $search_categ_sup=trim(GETPOST("search_categ_sup", 'int')); @@ -92,10 +92,11 @@ $search_stcomm=GETPOST('search_stcomm', 'int'); $search_import_key = GETPOST("search_import_key", "alpha"); $search_btn=GETPOST('button_search', 'alpha'); $search_remove_btn=GETPOST('button_removefilter', 'alpha'); +$search_fk_parent = GETPOST('search_fk_parent', 'alpha'); $type=GETPOST('type', 'alpha'); $optioncss=GETPOST('optioncss', 'alpha'); -$mode=GETPOST("mode", ''); +$mode=GETPOST("mode", 'alpha'); $diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id; @@ -195,6 +196,7 @@ $arrayfields=array( 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), + 's.fk_parent'=>array('label'=>'ParentCompany', 'checked'=>0), 's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 's.status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -263,6 +265,7 @@ if (empty($reshook)) $search_status=-1; $search_stcomm=''; $search_level=''; + $search_fk_parent=-1; $search_import_key=''; $toselect=''; $search_array_options=array(); @@ -308,6 +311,7 @@ if ($search_status=='') $search_status=1; // always display active thirdparty fi $form=new Form($db); $formother=new FormOther($db); $companystatic=new Societe($db); +$companyparent=new Societe($db); $formcompany=new FormCompany($db); $prospectstatic=new Client($db); $prospectstatic->client=2; @@ -342,7 +346,7 @@ $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; -$sql.= " s.code_compta,s.code_compta_fournisseur,"; +$sql.= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; $sql.= " typent.code as typent_code,"; $sql.= " staff.code as staff_code,"; $sql.= " country.code as country_code,"; @@ -419,6 +423,7 @@ if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= natural_search("s.fk_typent", $search_type_thirdparty, 2); if (! empty($search_staff) && $search_staff != '-1') $sql.= natural_search("s.fk_effectif", $search_staff, 2); if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); +if ($search_fk_parent && $search_fk_parent != '-1') $sql.= "s.fk_parent IN (".$search_fk_parent.")"; if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm", $search_stcomm, 2); if ($search_import_key) $sql.= natural_search("s.import_key", $search_import_key); // Add where from extra fields @@ -515,6 +520,7 @@ if ($search_type != '') $param.='&search_type='.urlencode($search_type); if (is_array($search_level) && count($search_level)) foreach($search_level as $slevel) $param.='&search_level[]='.urlencode($slevel); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm); +if ($search_fk_parent != '' && $search_fk_parent != '-1') $param.='&search_fk_parent='.urlencode($search_fk_parent); if ($search_import_key != '') $param.='&search_import_key='.urlencode($search_import_key); if ($type != '') $param.='&type='.urlencode($type); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); @@ -859,6 +865,12 @@ if (! empty($arrayfields['s.fk_stcomm']['checked'])) print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); print ''; + + print '
    '; + if ($companystatic->fk_parent > 0) + { + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(); + } + print "'; - + print ''; print ''; if ($companystatic->fk_parent > 0) From 065e74379bc1317fa392a78e56b61b123c22951f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Feb 2019 13:54:38 +0100 Subject: [PATCH 51/77] Missing picto --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c063d915036..3a1744451c1 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1204,7 +1204,7 @@ while ($i < min($num, $limit)) if ($companystatic->fk_parent > 0) { $companyparent->fetch($companystatic->fk_parent); - print $companyparent->getNomUrl(); + print $companyparent->getNomUrl(1); } print "
    '.$langs->trans("DefaultCustomerType").''; -print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT,'defaultcustomertype','defaultcustomertype','admin'); +print $formcompany->selectProspectCustomerType($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT, 'defaultcustomertype', 'defaultcustomertype', 'admin'); print ''; print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 5b6aa469059..99a7dbd9a1c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -838,7 +838,7 @@ if (! empty($arrayfields['customerorsupplier']['checked'])) { print ''; if ($type != '') print ''; - print $formcompany->selectProspectCustomerType($search_type,'search_type', 'search_type', 'list'); + print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list'); print ''.price($objp->am); if ($creditnotes) print '+'.price($creditnotes); - if ($deposits) print '+'.price($deposits); + if ($deposits) print '+'.price($deposits); print ''.price($remaintopay).'
    '."\n"; print ''; print ''; +print ''; print ''; print ''; print ''; @@ -89,6 +192,11 @@ print ''; print ''; print ''; print ''; +// Action column +print ''; print ''; print ''; @@ -99,11 +207,13 @@ print_liste_field_titre('UserUpdateCP'); print_liste_field_titre('Description'); print_liste_field_titre('Type'); print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); +print_liste_field_titre('Variation', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print ''; -foreach($cp->logs as $logs_CP) +foreach($object->logs as $logs_CP) { $user_action = new User($db); $user_action->fetch($logs_CP['fk_user_action']); @@ -111,6 +221,9 @@ foreach($cp->logs as $logs_CP) $user_update = new User($db); $user_update->fetch($logs_CP['fk_user_update']); + $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); + $detasign = ($delta > 0 ? '+' : '-'); + print ''; print ''; print ''; @@ -122,14 +235,16 @@ foreach($cp->logs as $logs_CP) print $label?$label:$logs_CP['fk_type']; print ''; print ''; + print ''; print ''; + print ''; print ''."\n"; } if ($log_holiday == '2') { - print ''; - print ''; + print ''; + print ''; print ''; } @@ -137,6 +252,8 @@ print ''."\n"; print '
    '; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
    '.$logs_CP['rowid'].''.$logs_CP['date_action'].''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'
    '.$langs->trans('NoRecordFound').'
    '.$langs->trans('NoRecordFound').'
    '."\n"; print ''; +print ''; + // End of page llxFooter(); $db->close(); From ed733fb82d9536561d4706352b1f19b45371b5bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 13:28:10 +0100 Subject: [PATCH 77/77] Fix phpcs --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 054f12d5bd1..4765c6b692d 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -949,7 +949,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); - $pdf->SetFont('','', $default_font_size - 4); + $pdf->SetFont('', '', $default_font_size - 4); $pdf->SetXY($tab3_posx, $tab3_top); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top);